//---------------------------------------------------------------------------------
void glRotatef32i(int angle, int32 x, int32 y, int32 z) {
//---------------------------------------------------------------------------------
    int32 axis[3];
    int32 sine = SIN[angle &  LUT_MASK];
    int32 cosine = COS[angle & LUT_MASK];
    int32 one_minus_cosine = inttof32(1) - cosine;

    axis[0]=x;
    axis[1]=y;
    axis[2]=z;

    normalizef32(axis);   // should require passed in normalized?

    MATRIX_MULT3x3 = cosine + mulf32(one_minus_cosine, mulf32(axis[0], axis[0]));
    MATRIX_MULT3x3 = mulf32(one_minus_cosine, mulf32(axis[0], axis[1])) - mulf32(axis[2], sine);
    MATRIX_MULT3x3 = mulf32(mulf32(one_minus_cosine, axis[0]), axis[2]) + mulf32(axis[1], sine);

    MATRIX_MULT3x3 = mulf32(mulf32(one_minus_cosine, axis[0]),  axis[1]) + mulf32(axis[2], sine);
    MATRIX_MULT3x3 = cosine + mulf32(mulf32(one_minus_cosine, axis[1]), axis[1]);
    MATRIX_MULT3x3 = mulf32(mulf32(one_minus_cosine, axis[1]), axis[2]) - mulf32(axis[0], sine);

    MATRIX_MULT3x3 = mulf32(mulf32(one_minus_cosine, axis[0]), axis[2]) - mulf32(axis[1], sine);
    MATRIX_MULT3x3 = mulf32(mulf32(one_minus_cosine, axis[1]), axis[2]) + mulf32(axis[0], sine);
    MATRIX_MULT3x3 = cosine + mulf32(mulf32(one_minus_cosine, axis[2]), axis[2]);
}
Exemple #2
0
void TunnelPartExec(int time)
{
	int i;
	int32 dir[3];
	
	CurrentTime = time;
	
	
	
	TunnelFxDraw((time>>6), sinLerp(time>>1), cosLerp(time>>1));
	
	
	
	glEnable(GL_BLEND);
		
	DiscoElephant->transform->translation[2] = floattof32(-1) + ABS(sinLerp(time)/2);
	DiscoElephant->transform->rotation[0] = (DEGREES_IN_CIRCLE/16);
	DiscoElephant->transform->rotation[1] = sinLerp(time*2) / 2;

	for(i=0; i<4; i++) {
		dir[0] = (DiscoElephant->transform->translation[0] - flares[i]->position[0]);
		dir[1] = (DiscoElephant->transform->translation[1] - flares[i]->position[1]);
		dir[2] = (DiscoElephant->transform->translation[2] - flares[i]->position[2]);
		
		normalizef32(dir);
		
		dir[0] *= 0.9;
		dir[1] *= 0.9;
		dir[2] *= 0.9;
		
		Scene->lights[i]->direction[0] = f32tov10(dir[0]);
		Scene->lights[i]->direction[1] = f32tov10(dir[1]);
		Scene->lights[i]->direction[2] = f32tov10(dir[2]);
	}

	RenderScene(Scene);	
		
	for(i=0; i<4; i++) {
		flares[i]->position[0] = DiscoElephant->transform->translation[0] + (int32)sinLerp((time<<1) + (i+1) * DEGREES_IN_CIRCLE/4)/2;
		flares[i]->position[1] = DiscoElephant->transform->translation[1] + (int32)cosLerp((time<<2) + (i+1) * DEGREES_IN_CIRCLE/4)/2;
		flares[i]->position[2] = DiscoElephant->transform->translation[2] + (int32)sinLerp((time<<3) + DEGREES_IN_CIRCLE/(i+1))/2;
		DrawBillboard(flares[i], false, 0, 0, 0, 0);
	}
	
	if(time < 1000) {
		FadeIn(time);
	} else if(time >= 28000) {
		FadeOut(time);
	} else {
		DrawFlash(time);
	}
	
	glFlush(0);
	swiWaitForVBlank();
}
Exemple #3
0
void updatePlayer(struct PLAYER * player, struct CAMERA * camera)
{
	scanKeys();
	int hold = keysHeld();

	player->yPos = -500;
	
	int vec[3];
	vec[0] = (2000 * sinLerp(camera->yRot)) / 4096;
	vec[1] = 0;
	vec[2] = (2000 * cosLerp(camera->yRot)) / 4096;

	if(!(vec[0] == 0 && vec[1] == 0 && vec[2] == 0))
		normalizef32(&vec[0]);

	//printf("%d, %d\n", xCam, zCam);
	printf("%d, %d\n", vec[0], vec[2]);

	if (hold & KEY_LEFT)
	{
		player->yRot += degreesToAngle(1);
		player->xPos += vec[0] * 15/ 4096;
		player->zPos += vec[2] * 15/ 4096;
	}
	if (hold & KEY_RIGHT)
	{
		player->yRot -= degreesToAngle(1);
		player->xPos += vec[0] * 15/ 4096;
		player->zPos += vec[2] * 15/ 4096;
	}
	if (hold & KEY_UP)
	{
			player->xPos += vec[0] * 20/ 4096;
			player->zPos += vec[2] * 20/ 4096;
			//not 100% correct, because when you press up and left together, you will not rotate!
			if(abs(player->yRot - camera->yRot) < 150) player->yRot = camera->yRot;
			else
			{
				if(camera->yRot > player->yRot) player->yRot += 150;
				if(camera->yRot < player->yRot) player->yRot -= 150;
			}
			//player->yRot = camera->yRot;
	}
	if (hold & KEY_DOWN)
	{
		player->xPos -= vec[0] * 20/ 4096;
		player->zPos -= vec[2] * 20/ 4096;
		if(abs(player->yRot - camera->yRot) < 150) player->yRot = camera->yRot;
	else
	{
		if(camera->yRot > player->yRot) player->yRot += 150;
		if(camera->yRot < player->yRot) player->yRot -= 150;
	}
		/*if(abs(player->yRot - (degreesToAngle(180) - camera->yRot)) < 300) player->yRot = (degreesToAngle(180) - camera->yRot);
	else
	{
		if(camera->yRot > (degreesToAngle(180) - camera->yRot)) player->yRot += 300;
		if(camera->yRot < (degreesToAngle(180) - camera->yRot)) player->yRot -= 300;
	}*/
	}
}