Esempio n. 1
0
static void
face_to_sphere (guVector *out, int face, float a, float b)
{
  guVector sphere;
  guVector eye = { 0, 0, -1 };

  switch (face)
    {
    case 0:  /* left */
      sphere.x = -1.0;
      sphere.y = -b;
      sphere.z = -a;
      break;

    case 1:  /* front */
      sphere.x = -a;
      sphere.y = -b;
      sphere.z = 1.0;
      break;

    case 2:  /* right */
      sphere.x = 1.0;
      sphere.y = -b;
      sphere.z = a;
      break;

    case 3:  /* back */
      sphere.x = a;
      sphere.y = -b;
      sphere.z = -1;
      break;

    case 4:  /* top */
      sphere.x = -a;
      sphere.y = 1.0;
      sphere.z = b;
      break;

    case 5:  /* bottom */
      sphere.x = -a;
      sphere.y = -1.0;
      sphere.z = -b;
      break;
    }

  /* We just need to add the "sphere" & eye vectors, then normalize.  */

  guVecNormalize (&sphere);
  guVecAdd (&sphere, &eye, out);

  if (out->x == 0 && out->y == 0 && out->z == 0)
    out->z += 0.0001;

  guVecNormalize (out);
}
Esempio n. 2
0
File: gu.c Progetto: comex/libogc
void guVecHalfAngle(Vector *a,Vector *b,Vector *half)
{
	Vector tmp1,tmp2,tmp3;

	tmp1.x = -a->x;
	tmp1.y = -a->y;
	tmp1.z = -a->z;

	tmp2.x = -b->x;
	tmp2.y = -b->y;
	tmp2.z = -b->z;

	guVecNormalize(&tmp1);
	guVecNormalize(&tmp2);

	guVecAdd(&tmp1,&tmp2,&tmp3);
	if(guVecDotProduct(&tmp3,&tmp3)>0.0f) guVecNormalize(&tmp3);

	*half = tmp3;
}