view.c
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*============================================================================
NuSYSTEM サンプルプログラム「SNAKE TAIL HACK」
view.c
Copyright (C) 1997, NINTENDO Co,Ltd.
============================================================================*/
#include <assert.h>
#include <nusys.h>
#include "main.h"
#include "graphic.h"
#include "para.h"
void SetViewMtx( Dynamic* );
void SetViewMtxGameOver( Dynamic* );
extern float View;
/*--------------------------------------*/
/* 視点マトリックスの設定(通常時) */
/* IN: dp ダイナミックポインタ */
/* RET:なし */
/*--------------------------------------*/
void
SetViewMtx( Dynamic* dp )
{
u16 perspNorm;
static LookAt lookat;
/* 投影マトリックスの計算と設定 */
guPerspective(&dp->projection, &perspNorm,
33, (float)SCREEN_WD/(float)SCREEN_HT, 10, 10000, 1.0);
guLookAtReflect(&dp->viewing, &lookat,
0,
cosf(2.0*M_PI/(360/(View+90.0)))*CAM_DISTANCE,
sinf(2.0*M_PI/(360/(View+90.0)))*CAM_DISTANCE,
0, 0, 0,
0, 1, 0);
gSPPerspNormalize(glistp++, perspNorm);
gSPLookAt(glistp++, &lookat);
gSPMatrix(glistp++, &(dp->projection),
G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
gSPMatrix(glistp++, &(dp->viewing),
G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH);
}
/*----------------------------------------------*/
/* 視点マトリックスの設定(ゲームオーバー時) */
/* IN: dp ダイナミックポインタ */
/* RET:なし */
/*----------------------------------------------*/
void
SetViewMtxGameOver( Dynamic* dp )
{
u16 perspNorm;
static LookAt lookat;
/* 投影マトリックスの計算と設定 */
guPerspective(&dp->projection, &perspNorm,
33, (float)SCREEN_WD/(float)SCREEN_HT, 10, 10000, 1.0);
guLookAtReflect(&dp->viewing, &lookat,
0,
0,
1500,
0, 0, 0,
0, 1, 0);
gSPPerspNormalize(glistp++, perspNorm);
gSPLookAt(glistp++, &lookat);
gSPMatrix(glistp++, &(dp->projection),
G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
gSPMatrix(glistp++, &(dp->viewing),
G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH);
}