Forum

Need some help with camera work

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Need some help with camera work

Postby vicious1988 » Thu Jan 27, 2011 1:52 am

Long time no post. I'm needing some help with some camera code for an AC130. No, its not a CoD clone. But the idea did come while playing it.

Right now my problem is getting the camera to focus on a vector (currently 0,0,0), and rotate within constraints. The camera's yaw bugs out when it goes beyond +/-180 and automatically goes to the side of the constraint that is within the +/-180. I also lose control over pitch when I call fixangle=1.

Code: Select all
   self.movetype = MOVETYPE_FLY;
   self.torigin = '0 0 0'; // what to focus towards
   self.tvec = vectoangles(self.origin-self.torigin);

   self.ty = self.tvec_y - 180;

// need to be within +/- 180
   if (self.ty < -180)
      self.ty + 360;
   if (self.ty > 180)
      self.ty - 360;
   
 // yaw constraints
   if (self.angles_y > self.ty + 80)
      self.angles_y = self.ty + 80;
   if (self.angles_y < self.ty - 80)
      self.angles_y = self.ty - 80;

// need to be within +/- 180
   if (self.angles_y > 180)
      self.angles_y - 360;
   if (self.angles_y < -180)
      self.angles_y + 360;

// pitch constraint
   if (self.angles_x > 0)
      self.angles_x = 0;

// debug output (heh, right)
   sprint(self,ftos(self.tvecy));
   sprint(self,"\n");
   sprint(self,ftos(self.anglesy));
   sprint(self,"\n");
   self.fixangle=1;


I'm calling this function in PostThink (tried in PreThink as well) only when the AC130 role is chosen. I already know its going to be something painfully obvious, practically shouting "RIGHT HERE!"

I'm also trying to determine the best way of moving the camera in a circle around the given vector since the camera is being used for aiming the armaments.
User avatar
vicious1988
 
Posts: 16
Joined: Sun Oct 12, 2008 10:14 pm

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest