Advertisement

ray collision to check what the camera is pointing on

Started by August 02, 2004 10:04 AM
-1 comments, last by JazzD 20 years, 4 months ago
Hey guys, this is basically an easy thing but I can't figure out why it isn't working: I want to check if my Camera is pointing on some object, if it is a bool should be returned as true. I've been trying to do it like this:

	for(i=0;i<num_OfEnemyOrcs;i++) {
			Npcs.Render();
			CVector3 pPoint=ClosestPointOnLine(GetCam().Position(),GetCam().View(), Npcs.origin);
			CVector3  pom=pPoint-GetCam().Position(); 
			pom = Normalize(pom);

			print("%f %f %f",pPoint.x,pPoint.y,pPoint.z);
			
			CVector3 *center=&Npcs.origin;

			if(abs(pPoint.x-center->x)<50)
			{
				if(abs(pPoint.y-center->y)<50)
				{
					if(abs(pPoint.z-center->z)<50)
					{
                        float dis=Distance3(pPoint,GetCam().Position());
                        if (!col || dis<mdist)
                        {
                              col=true;    
							  mdist=dis;    
							  colObj=i;
                        }
					}
				}
			}
		}
Tho that doesn't seem to work :(. Has anyone got a better solution or a fix? Thanks!
www.prsoftware.de

This topic is closed to new replies.

Advertisement