Jump to content


Getting an array of the vertices and indices from an ID3DXMesh?


  • You cannot reply to this topic
1 reply to this topic

#1 chillypacman

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 31 May 2007 - 01:51 PM

Hi all :)

I'm trying to create a method that will take out the vertices and indices of an ID3DXMesh and put them in an array so that I can use it to create a trimesh in ode.

Basically I want to do this:

dGeomID plane;

dTriMeshDataID triMesh;

...

	// Plane geometry

	const int indexes[6] = {2, 1, 0, 3, 2, 0};// <--- THIS

	const dVector3 triVert[4] = { //<------- AND THIS

		{ 10.0,  0.0,  10.0},

		{-10.0,  0.0,  10.0},

		{-10.0,  0.0, -10.0},

		{ 10.0,  0.0, -10.0}

	};

 

	triMesh = dGeomTriMeshDataCreate();

	dGeomTriMeshDataBuildSimple(triMesh, (dReal*)triVert, 4, indexes, 6);

	plane = dCreateTriMesh(space, triMesh, NULL, NULL, NULL);

	dGeomSetData(plane, "Plane");

	dGeomSetPosition(plane, 0, -10.0, 0);

Heres what I have so far and it doesn't work:

int* indexes;

	float* vert;


	LPDIRECT3DVERTEXBUFFER9 VB;

	LPDIRECT3DINDEXBUFFER9 IB;

	dVector3 triVert;

	

	model->GetVertexBuffer(&VB);

	model->GetIndexBuffer(&IB);


	memcpy_s(indexes, sizeof(IB), IB, sizeof(IB));

	memcpy_s(vert, sizeof(VB), VB, sizeof(VB));


If anyone could shed osme light on this it would be GREATLY appreciated :)

#2 Oybl

    New Member

  • Members
  • PipPip
  • 17 posts

Posted 31 May 2007 - 07:56 PM

You have to lock the buffers first, then you get a pointer to actual data





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users