Collision detection between ellipsoids and vertices.

xiaoxiao2021-03-06  35

For some special models, the accuracy of the collision with the envelopment box will have some deviations, especially when colliding with the cloaks behind the characters, the collision with ordinary envelopes will be very uncoordinated. At this time, the ellipsoid collision is especially important, then let's take a look at how to judge a collision of an ellipsoid and a vertex. First we need a data structure to describe a ellipsoid: vector3 midpoint; vector3 radius; vector3 direction; only one mid point, one direction, and a vector that describes three radius lengths can be complete in space Syrian smelon. Then we judge the idea to pass the coordinates of the ellipsoid (ellipse, not ellipsoid), and then look at the equation and whether it is less than 1, less than 1 is in the ellipsoid. The specific approach is: D3DXMatrixTranslation (& msource, Source-> X, Source-> Y, Source-> Z); D3DXMatrixTranslation (& MellipsoID, -scur.vmidpoint.x, -scur.vmidpoint.y, -scur.vmidpoint.z) ; D3DXMatrixMultiply (& mSource, & mSource, & mEllipsoid); XMatrixVecToVec (& mEllipsoid, & sCur.vDirection, & (D3DXVECTOR3 (1,0,0))); D3DXMatrixMultiply (& mSource, & mSource, & mEllipsoid); float x = mSource._41; float y = Msource._42; float z = msource._43; float a = scur.vradius.x; float b = scur.vradius.y; float c = scur.vradius.z; if (SQR (X) / SQR (a) SQR (Y) / SQR (B) SQR (Z) / SQR (C) <1.0) Return True; where XmatrixVectovec is implemented first, it is first calculated from the fork between two vectors, gets a vertical line, and then around The root line rotates the angle to take it out, you can get the two vector rotation together.

转载请注明原文地址:https://www.9cbs.com/read-64278.html

New Post(0)