🔒 Locked
Bounding Box Creation
Advertisement
Original Post
I''ve worked out some stuff with my "3d engine", and now the monster can turn thru 360 degrees, and can move in the direction he is facing. YAHOOOOO! However, I have come upon another problem. Collision detection. No! No! Don''t run away! All I want to know is how to use DirectX 8 to create a simple bounding box for a mesh (so as the monster doesn''t keep walking through a nearby power plant). I''ve looked around the documentation, and have seen functions like D3DXComputeBoundingBox etc, but I can''t figure out how exactly to use them. Can someone give me a couple of lines of source just to put me on the right track? Thanks in advance
---------------
I finally got it all together...
...and then forgot where I put it.
Okay, i had this idea last week. Have you ever used RECTs in 2d? I got an idea like that. Here''s my class. I''m making this up right on the spot so if its not totally correct sorry. What it does is alows you to set the values for the top left back corner and bottom right front corner. It also can do tests with points if they are in the box and returns either of the defines at the top.
Hmmm, I think i might even find this useful
|
Hmmm, I think i might even find this useful
Thanx very much for taking the time to reply, but I already have a class almost identical to yours: CD3DRect
I know, i know...public member data...but for a small class like that i think easy and fast access is more important.
Anyway, what I REALLY need to know is how to compute the bounding box of a 3d mesh in directX 8. Anyone?
---------------
I finally got it all together...
...and then forgot where I put it.
|
I know, i know...public member data...but for a small class like that i think easy and fast access is more important.
Anyway, what I REALLY need to know is how to compute the bounding box of a 3d mesh in directX 8. Anyone?
---------------
I finally got it all together...
...and then forgot where I put it.
Doesn''t D3DXComputeBoundingBox solve the problem?
Yeah i tried that, but i couldn''t figure out how to get the vertex buffer to pass to it (i''m using a mesh). I got all confused... And for some strange reason it accepts a BYTE**
---------------
I finally got it all together...
...and then forgot where I put it.
---------------
I finally got it all together...
...and then forgot where I put it.
Are AABBs good enough? If so, then just find the maximum and minimum x, y, and z values.
OBBS are a little more complicated...
|
OBBS are a little more complicated...
Well, erm, thanx again for the help...I could do that if I had the mesh''s vertices. I don''t have them. I could also use D3DXComputeBoundingBox - IF I had the vertices. Anyway, if anyone out there knows direct3d 8 and wants to help me...it would be appreciated.
P.S. My question is API-specific (Direct3D 8.0 to be precise)
---------------
I finally got it all together...
...and then forgot where I put it.
P.S. My question is API-specific (Direct3D 8.0 to be precise)
---------------
I finally got it all together...
...and then forgot where I put it.
Use ID3DXMesh->GetVertexBuffer() and then lock the buffer. Pass the returned pointer to D3DXComputeBoundingBox after casting it to PVOID.
d00d thanx! That helps alot!
---------------
I finally got it all together...
...and then forgot where I put it.
---------------
I finally got it all together...
...and then forgot where I put it.
Sorry to bump this post again but...
---------------
I finally got it all together...
...and then forgot where I put it.
---------------
I finally got it all together...
...and then forgot where I put it.
Above post was a mistake. I meant to add my new question in the same post, but i pressed enter to make a new line and it posted it! Sorry ''bout that...
---------------
I finally got it all together...
...and then forgot where I put it.
---------------
I finally got it all together...
...and then forgot where I put it.
OK, now for the question...
Firstly, if I want to get the current bounding box for a mesh, will I have to do this each frame? (Sounds like the vertex locking and mesh box computation would slow it down considerably).
Secondly, in order to get the right orientation for the bounding box, should I multiply it by the model''s world matrix? I''m kinda confused here, as I''m plodding blindly into the world of 3d without any solid knowledge of the maths involved - I''m hiding behind D3D API
---------------
I finally got it all together...
...and then forgot where I put it.
Firstly, if I want to get the current bounding box for a mesh, will I have to do this each frame? (Sounds like the vertex locking and mesh box computation would slow it down considerably).
Secondly, in order to get the right orientation for the bounding box, should I multiply it by the model''s world matrix? I''m kinda confused here, as I''m plodding blindly into the world of 3d without any solid knowledge of the maths involved - I''m hiding behind D3D API
---------------
I finally got it all together...
...and then forgot where I put it.
No, you don''t need to calculate the bounding box each frame. The bounding box should be calculated once. At each frame you''ll need to transform your bounding box with the world matrix in order to get the right orientation and position of the box. An alternative way is to mutiply the other object by the inverse of the world matrix of your mesh to get that object transformed into the world space of your mesh so that you can use the original bounding box without transformation.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement