View Full Version : Circular collision detection
06-10-2005, 10:37 AM
I have a program with trees that require me to calculate for collision detection. I can get how to detect if I'm touching the tree, but my problem is to make it so if I try to move even at an angle I don't get stuck. I am trying to make it so you would be able to run along a row of trees while looking at them like in games. Does anybody have any ideas?
06-13-2005, 12:27 PM
You could treat the tree like a wall which is perpendicular to the tree's vector relative to the camera. Then slide the camera against that wall like I'm doing in my example I posted.
That's what I'm planning to do.
06-13-2005, 12:42 PM
Ok, sounds great, but I don't know how to implement that. I have something that seems it could work, but I can't figure out how I could get it to work. Here is the code that I find might have some potential. Note: this code was meant for particles to face the cam at all time.
glGetFloatv( GL_MODELVIEW_MATRIX, matrix );
vector3_t right( matrix, matrix, matrix );
vector3_t up( matrix, matrix, matrix );
vector3_t p( x,y,z );
//Now create each particle:
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex3fv( (p + (right + up ) * -size ).v );
glTexCoord2f( 1.0f, 0.0f );
glVertex3fv( (p + (right - up ) * size ).v );
glTexCoord2f( 1.0f, 1.0f );
glVertex3fv( (p + (right + up ) * size ).v );
glTexCoord2f( 0.0f, 1.0f );
glVertex3fv( (p + ( up - right ) * size ).v );
glEnd();I'm not that great with vertex pointers I just prefer to define the x, y, and z points of each vertex
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.