Archived

This topic is now archived and is closed to further replies.

Bounbind Box Collision Responce

This topic is 5312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

very difficult subject my friend. you''ll need more than a few posts to answer that questions.

I would suggest you constraint the box''s movement with the planes it collidied with.

Constrain the position, velocity and forces. try something like this.



  

class CPlanes
{
Vector m_Normal;
float m_d;

void ConstainBox(CAABBox& Box, float fDamping)
{
Vector Support = Box.GetSupportPoint(m_Normal);

float Depth = d - (Support * m_Normal);

if (d < 0.0f)
return;

Box.m_Position += m_Normal * (Depth * fDamping);
}

void ConstainVector(Vector& V)
{
V -= (V * m_Normal) * m_Normal;
}
};

class CAABBox
{
CList<CPlanes> m_Constaints;

Vector m_Position;
Vector m_HalfSize;

Vector m_Velocity;
Vector m_Acceleration;

Vector GetSupportPoint(const Vector& Axis) const
{
Vector V = m_HalfSize;

if (Axis.x > 0.0f) V.x *= -1.0f;
if (Axis.y > 0.0f) V.y *= -1.0f;
if (Axis.z > 0.0f) V.z *= -1.0f;

V += m_Position;
return V;
}

void ApplyConstaints(void)
{
for(int iter = 0; iter < 10; iter ++)
{
for(int j = 0; j < m_Constaints.Size(); i ++)
{
m_Constraints[i].ConstrainBox(this, 0.1f);
m_Constraints[i].ConstrainVector(m_Velocity);
m_Constraints[i].ConstrainVector(m_Acceleration);
}
}
}
};


Share this post


Link to post
Share on other sites
thanks for your reply.but when my (bounding box)camera
collide with world,I need of the responce for sliding
effect.(LIKE quake3 half-life...)..


Thanks

Share this post


Link to post
Share on other sites
look at the articles section about collision detection there s an tutorial over at gamasutra that contains all you need spher ->AABB collision detection + the formulas for all these sliding effects

Share this post


Link to post
Share on other sites