D3DX8.Intersect
alright, i am trying to use the D3DX8.Intersect function - its driving me nuts - for collision detection. for right now im trying to get it to work with shots hitting stationary, non-rotated buildings.
i tile my map into 10x10 units with a buidling in some.
pseudo code
shot is in tile x,z
building in tile x,z?
yes cool check for collision
matrixtranslation tileMartix, tilex*10,0,tileZ*10
matrixmultiply newworldmatrix, tilematrix, worldmatrix <- ive tried swapping matrix order
matrixinverse invworldmatrix, det, newworldmatrix
d3dxvec3transformcoord NewPos, origPos, invworldmatrix
newDir = standard cos/sin(origRadian) x z * 10
d3dx8.intersect buildingmesh, NewPos, newDir
basically trying to get shots vector in model space of the building, while maintaining its relationship.
ive tried all sorts of combinations with no luck. sometimes i get hits but it never makes sense.
thanks for any help you can give
I recently dealt with the same problems and D3DXInteresect does work. The two things that I'd consider is your matrix multiplication order ( you should be able to set up cases you can check in the debugger ) and this line:
newDir = standard cos/sin(origRadian) x z * 10
Not sure what that is for. After I build the matrix to transform the position and direction of the ray I call D3DXTransformCoord on the position and D3DXTransformNormal on the direction.
Jack
[edited by - JackNathan on July 29, 2002 9:53:34 AM]
newDir = standard cos/sin(origRadian) x z * 10
Not sure what that is for. After I build the matrix to transform the position and direction of the ray I call D3DXTransformCoord on the position and D3DXTransformNormal on the direction.
Jack
[edited by - JackNathan on July 29, 2002 9:53:34 AM]
damn posted a reply but errored out - now to type it all again, i hit post, then came back later and just shutdown my machine
newDir.x = xpos +cos(origRadian)* 10
newDir.z = zpos +sin(origRadian)* 10
(might have cos/sin reversed, not in front of my code right now)
but just putting the lookat vector out in front of the d3dxvec3transformcoord vector.
i debug by rendering a stationary shots at vNewOrig and one at vNewDir to see where they are at. they appear to be correctly moved back into model space of the building
havent used the debugger before, ill should probably check it out.
does intersect look at all subsets of a mesh automatically?
thanks, ill look at multiplication again.
newDir.x = xpos +cos(origRadian)* 10
newDir.z = zpos +sin(origRadian)* 10
(might have cos/sin reversed, not in front of my code right now)
but just putting the lookat vector out in front of the d3dxvec3transformcoord vector.
i debug by rendering a stationary shots at vNewOrig and one at vNewDir to see where they are at. they appear to be correctly moved back into model space of the building
havent used the debugger before, ill should probably check it out.
does intersect look at all subsets of a mesh automatically?
thanks, ill look at multiplication again.
ahhg figured it out - math was right - however im doing a tank game. to make the shot mesh i just put it at the end of the barrel in Milkshape then exported just the shot. np but my Y on it would be 0 (just doing X Z space right now). so when putting vectors into intersect the ray it made was under the building
heheheheheeeeee
think ill go back and center all my models.
heheheheheeeeee
think ill go back and center all my models.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement