Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

cheese and crackers

Sign in to follow this  


Well, I bought Half-Life 2 yesterday. Mostly for the Counter Strike 'mod' that is included. If its bundled with the software, I dont really consider it a mod, but you get it. I play as hatekick, phear me. ;) Naw, I still suck.

Long story short, I'm still a shitty coder I guess. I need to rewrite a function that is dependant on a class being pased as an argument. It solves t for sphere to plane collision. Some of the first attempt code is commented out.

float CColSphere::CollideAABB(const CColAABB &s, float tcount)
Vector3 S = Internal;
Vector3 D = Direction * Velocity * tcount;
Vector3 P = s.Internal + s.ClosestToPoint(S - s.Internal);
Vector3 C = S - P;
Vector3 N = Normalize3( C );
//Vector3 R = S + ( N * -Radius );

float d = ( C * N ) - Radius;
float u = ( d - ( C * N ) + Radius );
float f = ( D * N );

//float f = N * ( Direction * Velocity * tcount );
//float u = ( R - C ) * N;

float t = u / f;
if(t <= 0.0f)
Vector3 b = s.ClosestToPoint(Internal - s.Internal);
Vector3 c = (Internal - (b + s.Internal));
Direction.x = -Direction.x;

Direction.z = -Direction.z;

if(c.x && c.z)
Direction = c;

if( s.Contains( Internal - s.Internal ) )
Direction = Internal - s.Internal;

Direction = Normalize3(Direction);
return 1.0f;
if(t < 1.0f && t > 0.0f)
return t;
return 0.0f;

Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!