Esempio n. 1
0
def _LookAtMatrix(at, eye, up=[0, 1, 0], reflect=False):
    """Define a matrix looking at.

  Arguments:
    *at* 
      tuple (x,y,z) of point camera pointed at, floats
    *eye*
      matrix [x,y,z] position of camera, floats

  Keyword arguments:
    *up*
      array vector of up direction
    *eflect*
      boolean if matrix is reflected
  """
    # If reflect, then reflect in plane -20.0 (water depth)
    if reflect:
        depth = -20.0  # Shallower to avoid edge effects
        eye = [eye[0], -eye[1], eye[2]]
        at = [at[0], -at[1], at[2]]
    zaxis = vec_normal(vec_sub(at, eye))
    xaxis = vec_normal(vec_cross(up, zaxis))
    yaxis = vec_cross(zaxis, xaxis)
    xaxis.append(-vec_dot(xaxis, eye))
    yaxis.append(-vec_dot(yaxis, eye))
    zaxis.append(-vec_dot(zaxis, eye))
    z = [0, 0, 0, 1.0]
    return array([[xaxis[a], yaxis[a], zaxis[a], z[a]] for a in range(4)],
                 dtype=ctypes.c_float)
Esempio n. 2
0
def _LookAtMatrix(at, eye, up=[0, 1, 0], reflect=False):
  """Define a matrix looking at.

  Arguments:
    *at*
      tuple (x,y,z) of point camera pointed at, floats
    *eye*
      matrix [x,y,z] position of camera, floats

  Keyword arguments:
    *up*
      array vector of up direction
    *eflect*
      boolean if matrix is reflected
  """
  # If reflect, then reflect in plane -20.0 (water depth)
  if reflect:
    depth = -20.0 # Shallower to avoid edge effects
    eye[1] *= -1
    at[1] *= -1
  zaxis = vec_normal(vec_sub(at, eye))
  xaxis = vec_normal(vec_cross(up, zaxis))
  yaxis = vec_cross(zaxis, xaxis)
  xaxis.append(-vec_dot(xaxis, eye))
  yaxis.append(-vec_dot(yaxis, eye))
  zaxis.append(-vec_dot(zaxis, eye))
  z = [0, 0, 0, 1.0]
  return np.array([[xaxis[a], yaxis[a], zaxis[a], z[a]] for a in range(4)],
               dtype="float32")