Exemplo n.º 1
0
void myCamera::MoveForwardBack(float t)
{
	GLfloat f[3] = {w[0], 0, w[2]};
	GLfloat* r = normalize(f);

	pos[0] += t*r[0];
	pos[1] += t*r[1];
	pos[2] += t*r[2];

	delete[] r;

	generateT();
}
Exemplo n.º 2
0
void myCamera::MoveLeftRight(float t)
{
	GLfloat f[3] = {u[0], 0, u[2]};
	GLfloat* r = normalize(f);

	pos[0] += t*r[0];
	pos[1] += t*r[1];
	pos[2] += t*r[2];

	delete[] r;

	generateT();
}
Exemplo n.º 3
0
void myCamera::move(float x, float y, float z)
{
	float move_amount = WALK_SPEED;
	if (isSprinting && sprintTime > 0)	//If you can sprint
	{
		move_amount = SPRINT_SPEED;
		setMoveSpeed(move_amount);
		sprintTime -= .25;
	}
	else
	{

	}
	
	pos[0] += move_amount*x;
	pos[1] += move_amount*y;
	pos[2] += move_amount*z;

	if (isSprinting && sprintTime > 0)
	{
		pos[1] += .005 * sin(1.3 * wave);		
	}
	else
	{
		pos[1] += .005 * sin(.9 * wave);
	}
	
	wave += .2;
	if (.2 * sin(2 * wave) > 3.14)
	{
		wave = 0;
		pos[1] = .6;
	}

	generateT();
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
void myCamera::moveAlongZ(float t)
{
	pos[2] += t;

	generateT();
}
Exemplo n.º 6
0
void myCamera::moveAlongY(float t)
{
	pos[1] += t;

	generateT();
}
Exemplo n.º 7
0
void myCamera::moveAlongX(float t)
{
	pos[0] += t;

	generateT();
}