Skip to main content
gamedev.net
🔒 Locked

Collision Frustrations

Started by RhoneRanger May 1, 2003 at 9:34 AM 8 replies 700+ views
Original Post
RhoneRanger
RhoneRanger
I am trying to implement a ray/poly test on my meshes in DX9, and I am having problems getting transformed data from my models. I dont use X files, so telling me to use D3DX in this matter will not do. How do I get the vertices transformed position into my mesh data? Basically I am loading the mesh from a file, and storing data in system memory. Now, I am trying to transform the vertice data according to the world transformation, but the results are less than desirable. I also read once on this forum to transform your world coordinates into the object''s coordinates. This would be easier, since I have the vertices original placement from the model but I am not sure how to do that either. Any help would be appreciated!
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Pipo DeClown
Pipo DeClown
*warning: no answer*

So you are making a ID3DXMesh for your mesh, to do CD?
I''m loading MD2''s and I''m lookign for a way to do collision detection too, but is this the right way?

.lick
GekkoCube
GekkoCube
Wow.
I''m trying to use MD2 models with DirectX9.
And my plan was to use simple bounding spheres.
I didnt know you could perform collision detection at mesh-level!

If you figure this out, please say so...as I and probably a few others will be very interested in knowing how to do just that!

RhoneRanger
RhoneRanger
okay, of course I have my up, look, and right vectors
and my position.

All you need to do is multiply all these by the model matrix?

That seems like a lot of wasted time! Is their an easier/better way?

And for all others:

I do use spheres for a lot of collision tests, but to get more accurate CD, if I cross the bounding sphere, then cast a ray to see if it hits a poly.

I got collision detection working fine for my landscape, but it is these transformed models that are posing a problem.

I am NOT using id3dx mesh just to reiterate.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
mdias
mdias
quote:
Original post by RhoneRanger
I dont use X files, so telling me to use D3DX in this matter will not do.



You can use D3DX without using X files by doing this:

D3DXCreateMeshFVF();

Mesh->LockVertexBuffer();
Mesh->LockIndexBuffer();

... // Fill in the vertex and index buffers

Mesh->UnlockVertexBuffer();
Mesh->UnlockIndexBuffer


then if you want to transform your mesh''s coordinates to world
coordinates you can try D3DXVec3TransformCoord

I hope this helps


KaM1KaZ3
RhoneRanger
RhoneRanger
The whole point I am making is that I want to do collision on models in world space. I have very good and fast functions for collisions, but all I need to do is to fill the copy of vertices of the object I have in system memory with the position of the Transformed vertices. That''s all.

I don''t want to lock and unlock vertex/index buffers every frame, when all I have to do is this:

If you are in same area as model:

perform sphere/sphere test.

if you intersect spheres:
perform ray-triangle test on mesh.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
Mark Duffill
Mark Duffill
Here are a few suggestions:

You do not want to try and retrive the transformed mesh from DX, as this will hinder performance.

It is cheaper and easier to transform the ray/sphere or whatever into the models local space because:

1) tranforming the start/end point ( and possibly direction ) vectors is far cheaper than rotating every vert in a mesh to world space.

2) if you have the mesh instanced twice in the world you would have to store 2 transformed meshes, or do it several times a frame.

3) You want to do collision on the CPU, not the GPU as this will cause stalls -> lower performance.

There have been many threads discussing similar issues, it might be a good idea to look into those too.

Other people have good advice on this topic (See threads by Simon O''Conner amongst others )

hope this is of some help.
RhoneRanger
RhoneRanger
Mark, thanks for the reply!

So all I need to do is transform my ray into model space. I will look into Simons posts, and I appreciate the help!
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.