RayTracing Translate/Rotate Camera C/C++
<p>First of all, please excuse my bad english.</p>

<p>I face a problem with my raytracing program. I want to move my camera around my scene with some keys shortcuts. I want to have the possibility to rotate it and moving forward, backword, right, left...</p>

<p>The problem is that I have some difficulties to do it.
How my camera is defined ?</p>

<pre><code>t_cam   *CameraInit(t_vec vCamPos, t_vec vUpVector)
{
  t_cam *cam;

  if ((cam = bunny_malloc(sizeof(*cam))) == NULL)
    {
      print_error("Error: bunny_malloc error\n");
      return NULL;
    }
  cam-&gt;camPos = vCamPos;
  cam-&gt;upVec = vUpVector;
  cam-&gt;viewPlanDist = 0.5f;
  cam-&gt;viewPlanHeight = 0.35f;
  cam-&gt;viewPlanWidth = 0.5f;
  return cam;
}

t_cam   *Camera(t_vec camPos, t_vec lookAtPoint, t_vec upVector, char *name)
{
  t_vec tmp;
  t_vec tmp2;
  t_cam *cam;

  if ((cam = CameraInit(camPos, upVector)) == NULL)
    return NULL;
  cam-&gt;name = name;
  cam-&gt;lookAtPoint = lookAtPoint;
  cam-&gt;vecDir = VecSoustraction(lookAtPoint, camPos);
  Normalize(&amp;cam-&gt;vecDir);
  printf("VecDir = x: %f y: %f z: %f\n", cam-&gt;vecDir.x, cam-&gt;vecDir.y, cam-&gt;vecDir.z);
  cam-&gt;rightVec = VecMultiply(cam-&gt;upVec, cam-&gt;vecDir);
  cam-&gt;upVec = VecMultiply(cam-&gt;vecDir, cam-&gt;rightVec);
  tmp = VecScalingMult(cam-&gt;vecDir, cam-&gt;viewPlanDist);
  tmp2 = VecScalingMult(cam-&gt;upVec, cam-&gt;viewPlanHeight / 2.0f);
  tmp = VecAddition(tmp, tmp2);
  tmp = VecAddition(tmp, cam-&gt;camPos);
  tmp2 = VecScalingMult(cam-&gt;rightVec, cam-&gt;viewPlanWidth / 2.0f);
  cam-&gt;viewPlanUpLeft = VecSoustraction(tmp, tmp2);
  return cam;
}
</code></pre>

<p>Where VecScalingMult just muliply each component of the vector (x, y, z) by a coefficient.
So I have a UpVector, RightVector, a DirVector Normalized, 
the point at which looks the camera and the camera position.</p>

<p>Do you have any idea how to rotate and move the camera in the 3D space ?</p>

<p>Thanks</p>