Opengl Robot.c

Hey everyone!

I have a term project due for school in a few days, it consists of making a fully moveable robot that can move around a set grid, move all its limbs, has three objects that it cannot pass through, and must be able to toggle from first to third person view..

I have completed everything except the first person view code and collision detection code..

What I need help in is for the code I have not yet completed. I know that for the first person view I can use the lookAt function but I can't make heads or tails of it all, and the collision detection far surpases my abilities of programming at this moment in time.

So if anyone can offer any help or show me some code on how to get these two things done it would be appreciated more than you know. The Robot file is coded in C.

Below is the code that I have completed so far, I'm also using a simple Makefile program to compile it all and create an exe for the program.

For the first person camera, you could try using glLookAt, by setting the camera / eye position to be at the center of the head, and then placing the look at target on a unit sphere (centered on the eye position) based in the direction that the character is looking.

For the collision detection, you could do something simple with either bounding boxes, bounding spheres, or even bounding cylinders (if the motion is strictly on a plane, which it seems like it is). For the latter, you could simply save a copy of the current position, and have another copy that is updated. Then check to see if the distance between the collision object and the character is less than a specified bounding circle around the player plus the bounding circle around the object. If the two circles are overlapping, then you could leave the position at the current position and not update it. For bounding boxes / squares, since you only have three objects to worry about, you could do the same thing, checking each point on the character to see if they are within the box of the collision objects.

A general thinking way of dealing with collision is dealing with collision of triangles, given two triangles, you can write a no complex algorithm to detect if these two triangles are collided. So the whole situation can be handled in this way, the first level collision test is to detect if two objects' bounding boxes or spheres are collided, if so, the second level collision test is to test a pair of triangles one from the first object and the other from the second object whether they're collided.

A general thinking way of dealing with collision is dealing with collision of triangles, given two triangles, you can write a no complex algorithm to detect if these two triangles are collided. So the whole situation can be handled in this way, the first level collision test is to detect if two objects' bounding boxes or spheres are collided, if so, the second level collision test is to test a pair of triangles one from the first object and the other from the second object whether they're collided.

I'm sorry, the above method of collision test is so crude that only adequate for very simple situation where faces are no more than several hundred. Anyway, collision detection is a complex domain that has been researched for several decades. If you are interested in that, reading some books is necessary, for example, "Real time collision detection" and others. I apologize for having provided junk information.