Sign in to follow this  
Kurt-olsson

collision detection of rotated vertex_buffer

Recommended Posts

Kurt-olsson    254
i have a big static vertex_buffer that is my gamelevel.

i can transform it and rotate/scale etc with DirectXAPI.
But if i want to perform calculations for my collision detection i need the transformed vertex points in my vertex_buffer.

is there a way i can copy back a transformed vertex_buffer so i can test all my triangles for collision detection.

Or should i perform transformation on my vertexbuffer before i copy them for rendering?

Share this post


Link to post
Share on other sites
WiredCat    1452
why do you tarnsform your level? eys you should transform verts once and then check collision or store two vb one standard second rotated, if you want to check for collision transformed vert in fly you should consider that this will require more computations = slower, so transform them one and then check, BUT the best solution for you(if your scene objects are in example always rtoating ) transform the collision test points not whole vertex array, do you understand me? Edited by ___

Share this post


Link to post
Share on other sites
Kurt-olsson    254
yeah i think i understand.
It is in the way you say with my level. i want lots of parts of my level to roate and go from different positions. Kind of like Uncharted game when the floor gives in and the player slides down.

i think the best way for me would be to transform my vertex array before i copy it to the buffer. that way i always have the updated array.

But it feels not good doing this because all my rotations is made by the CPU right?
can i user D3DXMatrixRotate.. on a vertex-struct array?

It would be great if i could use the DirectX API as usual for transforming my verticies...

Share this post


Link to post
Share on other sites
SimonForsman    7642
You could just apply the same transformations to the collision shapes in the physics engine. (Even if you run your physics on the CPU the collision shapes should be far less complex than the actual geometry so CPU side transformations of these won't be as expensive)

Share this post


Link to post
Share on other sites
Krohm    5030
[quote name='KurtO' timestamp='1349767617' post='4988245']
Kind of like Uncharted game when the floor gives in and the player slides down.[/quote]I bet this floor is not part of the level. It's likely an entity which gets drawn very similarly to the level.

[quote name='KurtO' timestamp='1349767617' post='4988245']i think the best way for me would be to transform my vertex array before i copy it to the buffer. that way i always have the updated array.[/quote]In Bullet, your level would be a shape. From that, we would create a rigidbody using that shape, and the rigidbody would apply a transformation to the shape. This is the established way to approach this problem and I'm inclined to think it is the best way.

Share this post


Link to post
Share on other sites
Anddos    588
[quote name='Krohm' timestamp='1349852496' post='4988628']
[quote name='KurtO' timestamp='1349767617' post='4988245']
Kind of like Uncharted game when the floor gives in and the player slides down.[/quote]I bet this floor is not part of the level. It's likely an entity which gets drawn very similarly to the level.

[quote name='KurtO' timestamp='1349767617' post='4988245']i think the best way for me would be to transform my vertex array before i copy it to the buffer. that way i always have the updated array.[/quote]In Bullet, your level would be a shape. From that, we would create a rigidbody using that shape, and the rigidbody would apply a transformation to the shape. This is the established way to approach this problem and I'm inclined to think it is the best way.
[/quote]

do you have a sample of that with directx and bullet?

Share this post


Link to post
Share on other sites
Krohm    5030
It is a common misconception that Physics has anything to do with graphics. I'm afraid this code does not exist, if it exists, you're better not take it as example.
People using this approach would likely start from [url="http://bulletphysics.com/Bullet/BulletFull/classbtBvhTriangleMeshShape.html"]btBvhTriangleMeshShape[/url].
Personally I am not a big fan of using a single shape for the whole world so no, I don't have that code available myself. There's a library example however.
Keep in mind that the concept applies to all other shapes as well, let them be a box or a sphere.

Share this post


Link to post
Share on other sites
Kurt-olsson    254
I completely agree with you guyes, but my project is very simple and my level will be only about 2-3000 faces
so i think it is best to combine my "graphics-level" and "physics-level" in one.

I might build a muuuch more simple mesh in blender that will represent collision forms only.
But i almost only have boxes and simple shapes so the triangle count is very low.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this