示例#1
0
void myCamera::increaseAspect()
{
    if (type == PERSP)
    {
        aspect = aspect * 4.0 / 3.0;
        generateS();
    }
    else if (type == ORTHO)
    {
        right += 1;
        left -= 1;
        generateS();
    }
}
示例#2
0
void myCamera::switchType()
{
    // switch camera type, reload S
	if (type == PERSP)
	{
		type = ORTHO;
		generateS();
	}
	else
	{
		type = PERSP;
		generateS();
	}
}
示例#3
0
void myCamera::decreaseAspect()
{
    if (type == PERSP)
    {
        aspect = aspect * 3.0 / 4.0;
        generateS();
    }
    else if (type == ORTHO)
    {
        if((right - 1) > 0 && (left + 1) < 0)
        {
            right -= 1;
            left += 1;
            generateS();
        }
    }
}
示例#4
0
void myCamera::increaseHeight()
{
    if (type == PERSP)
    {
        if (fovy + 5 < 140)
        {
            fovy += 5;
            generateS();
        }
    }
    else if (type == ORTHO)
    {
        top += 1;
        bottom -= 1;
        generateS();
    }

}
/**
 *generateV - calculates the sum of the squared error for all variables
 *
 *  @param a            the parameters to calculate V
 *  @param x            the variables to calculate V
 *  @param S_measured   the measured S values
 *  @param paramSize    number of parameter elements
 *  @param measSize     number of measurements of S
 *  @return             the squared error
 */
double generateV(double *a, double *x, double *S_measured,
                 int paramSize, int measSize)
{
  double V = 0;
  for(int i = 0; i < measSize; i++)
  {
    V += pow(generateS(a, &x[i], paramSize) - S_measured[i], 2.0);
  }
  return V;
}
示例#6
0
void myCamera::adjustNear(float t)
{
    // move the near clipping plane by t
	if ((zNear + t) < zFar && (zNear + t) > 0)
	{
		zNear += t;
	}
	generateS();
	generateM();
}
/**
 * generateS - for power law; generating an array of S values
 *  
 *  @param a      parameters to calculate S
 *  @param x      variables to calculate S
 *  @param S      results stored in this array; S
 *  @param asize  number of parameters
 *  @param xsize  number of variables
 */
void generateS(double* a, double* x, double* S, int asize, int xsize)
{
  if(asize <= 0 || xsize <= 0)
    return;

  for(int j = 0; j < xsize; j++)
  {
    S[j] = generateS(a, &(x[j]),asize);
  }

}
示例#8
0
void myCamera::decreaseHeight()
{
    if (type == PERSP)
    {
        if (fovy - 5 > 10)
        {
            fovy -= 5;
            generateS();
        }
    }
    else if (type == ORTHO)
    {
        if((top - 1) > 0 && (bottom + 1) < 0)
        {
            top -= 1;
            bottom += 1;
            generateS();
        }
    }
}
示例#9
0
void myCamera::zoomOut()
{
    // zoomOut = increasing fov
    if (type == PERSP)
    {
        if (fovy + 5 < 140)
        {
            fovy += 5;
            generateS();
        }
    }
    else if (type == ORTHO)
    {
        top += 1;
        bottom -= 1;
        right += 1;
        left -= 1;
        generateS();
    }
}
示例#10
0
void myCamera::adjustFar(float t)
{
    // move the far clipping plane by t
	if (zFar + t > zNear)
	{
		zFar += t;
	}

	generateS();
	generateM();
}
示例#11
0
void myCamera::zoomIn()
{
    // zoomIn = decreasing fov
    if (type == PERSP)
    {
        if (fovy - 5 > 10)
        {
            fovy -= 5;
            generateS();
        }
    }
    else if (type == ORTHO)
    {
        if((top - 1) > 0 && (bottom + 1) < 0 && (right - 1) > 0 && (left + 1) < 0)
        {
            top -= 1;
            bottom += 1;
            right -= 1;
            left += 1;
            generateS();
        }
    }
}
示例#12
0
myCamera::myCamera(float posx, float posy, float posz, float atx, float aty, float atz, float upx, float upy, float upz, int t)
{
	move_speed = 0;

	wave = 0;
	isSprinting = false;
	sprintTime = 100;
    type = t;

    fovy = 65.0;
    aspect = 1.0;
    zNear = .1;
    zFar = 200.0;
	top = 5;
	bottom = -5;
	left = -5;
	right = 5;

    pos[0] = posx;
    pos[1] = posy;
    pos[2] = posz;
    pos[3] = 1.0;

    look[0] = atx;
    look[1] = aty;
    look[2] = atz;
    look[3] = 1.0;

    up[0] = upx;
    up[1] = upy;
    up[2] = upz;

    GLfloat* r = normalize(look);

    w[0] = -r[0];
    w[1] = -r[1];
    w[2] = -r[2];

	delete[] r;

    GLfloat up_w = dot_product(up, w);

	// mult_w = (up dot w) * w
	GLfloat *mult_w = scalar_mult(up_w, w);

	// up_sub_mult_w = up - (up dot w)*w;
	GLfloat* up_sub_mult_w = vector_subtract(up, mult_w);

	r = normalize(up_sub_mult_w);

    v[0] = r[0];
    v[1] = r[1];
    v[2] = r[2];

	delete [] r;

    r = cross_product(v, w);
    u[0] = r[0];
    u[1] = r[1];
    u[2] = r[2];

    generateT();
    generateR();
    generateS();
	generateM();

	delete [] mult_w;
	delete [] up_sub_mult_w;
	delete [] r;
}