By the way, those functions are for "smooth" follows...
cx,cy,cz are for camera x,y,z
px,py,pz are for the points x,y,z
Distance is how far behind or infront you want the camera to stop..
you can modify these functions to do whatever you need them to do.
Or you can just move cx, cy, cz manually if you just want to move the camera, and not the point.. but by using functions like these, you can move the point, and have the camera follow, and always point in the direction you want... just remember not to move the point to fast, or else the camera won't be able to keep up ;).. or you can change /100 to like.. /10 or /32 or any other number your head can think of.
Billy
Disclaimer I have never tried either of these functions, so if you blow up your monitor it's not my fault.
Main Topics
Browse All Topics





by: Ready4DisPosted on 2000-12-28 at 11:18:47ID: 52603
Sure... although, this could have been posted in 3D Programming ;)
gluLookAt(
cx,cy,cz //Camera x,y,z
lx,ly,lz //Point to look at..
tx,ty,tz); //Camera Tilt..
to move camera around, simply move around cx, cy, cz...
to move what the camera points at simply move lx, ly, lz..
camera tilt.. well, I don't fully understand what it does.. but I know you can flip view upside down with ty=-1
.. haven't really played with it much though.
if lx,ly, and lz stay the same, and cx,cy,cz rotate about that point.. you get the camera to rotate about the object while facing it.
void Chase_Point(float &cx, float &cy, float &cz, float px, float py, float pz)
{
cx += (px-cx)/100; //Modify 100 for speed of chasing...
cy += (py-cy)/100; //Modify 100 for speed of chasing...
cz += (pz-cz)/100; //Modify 100 for speed of chasing...
}
Simple function to say follow a specific point.. if that point is static, it will evenually be that point. If you would like to follow right behind a point.. say the cener of an object, but never get to close
void Chase_Point_Distant(float &cx, float &cy, float &cz, float px, float py, float pz, float Distance)
{
cx += (px-cx)/100;
cy += (py-cy)/100;
cz += ((pz-Distance)-cy)/100; //Behind is +, ahead is -.
}
Simple enough right ;)
Any more questions, just post em up.