[ODE] Help using ODE with DirectX

Duncan Frostick duncanf at f2s.com
Thu Aug 26 14:03:43 MST 2004


Hi Jon,

Indeed! It's very trivial and that's exactly what I'm trying to do, 
except that I haven't got a struct for ODE cos I thought I'd just put it 
staight into dVector3's (as in the trimesh test code). But I'm getting a 
crash:

int numVertices = in->GetNumVertices(); //'in' is the mesh var
dVector3 *verticesODE;
verticesODE = (dVector3*) malloc(sizeof(dVector3)*numVertices);
//is this enough? One dVector3 for each vertex?
Vertex* verticesDX = 0;
//Vertex is a simple FVF struct with xyz, norms and tex coords
in->LockVertexBuffer(0,(void**)&verticesDX);
	
for (int i = 0; i<numVertices; i++) {
	dVector3 temp;
	temp[0] = verticesDX[i]._x; //crashes here
	temp[1] = verticesDX[i]._y;
	temp[2] = verticesDX[i]._z;
	temp[3] = 0.0f;
	verticesODE = &temp;
	verticesODE++;
}

in->UnlockVertexBuffer();

Though output that's I've placed on different lines I know where it 
crashes (indicated above), and I know that the element verticesDX[i] 
isn't null at that point because I can output the contents of it before 
the line that causes the crash. So temp must be null or something, but 
how? And the weird thing is that it'll work through 2163 iterations (of 
3162 vertices total) fine, then crash. That made me think I wasn't 
allocating enough memory for the process, so I quadrupled the memory and 
the same thing still happened. C/C++ isn't my first language (Java 
is...), I'm learning proper non-trivial C++ as I go along - so I'm 
thinking I'm making a schoolboy error with some pointers, but I don't 
know how. Any ideas?

Cheers, Duncan


More information about the ODE mailing list