Hi all, excuse my pseudo code.
Can you confirm my method for determining collisions.
I have given my player model a bounding cube (so i dont have to check all the humps and bumps colliding, rather just one plane).
I know that the plane that faces the direction im walking can be represented by 3 vertices:
var frontPlane = [p1, p2, p3] //gives a way of measuring distance from player to object points
var normalOfFrontPlane = [v1x, v1y, v1z] //gives a direction of that plane
I know that the current object (objects that are not my player) I’m iterating through has many normals/planes.
If I find the dot product (cosine) between my players normalFrontPlane and all the normals on the object im currently checking.
if ( cos <= 90 )
then find the distance between any 2 points on that plane (including the vertices that create the plane itself) -
sqrt((x2-x1)² + (y2-y1)² + (z2-z1)²)
if that distance is <= playerMaxCloseness, then movement stops.
Does that sound right? If so… great. tell me, coz im unsure.
Second question is, is there a better way to do all this in the shader file?
It seems like this operation would be quite slow?