Mercurial > hg > Game > Cerium
comparison Renderer/Test/hit_judge.cc @ 540:4c5264373c51 draft
reorganization
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 12 Oct 2009 09:43:07 +0900 |
parents | Renderer/Application/hit_judge.cc@3bc98f6d31ff |
children |
comparison
equal
deleted
inserted
replaced
539:3bc98f6d31ff | 540:4c5264373c51 |
---|---|
1 #include "SceneGraph.h" | |
2 #include "hit_judge.h" | |
3 #include "SGList.h" | |
4 | |
5 #define FUSELAGE_W 6 | |
6 #define FUSELAGE_H 6 | |
7 #define FUSELAGE_Z 6 | |
8 #define E_PLANE_W 6*4 | |
9 #define E_PLANE_H 6*4 | |
10 #define E_PLANE_Z 6*4 | |
11 #define BULLTE_W 2*4 | |
12 #define BULLTE_H 6*4 | |
13 #define BULLTE_Z 2*4 | |
14 | |
15 int | |
16 square_judge(SceneGraphPtr oneself, SceneGraphPtr partner) | |
17 { | |
18 int ow = 0, oh = 0, oz = 0; | |
19 int pw = 0, ph = 0, pz = 0; | |
20 if (oneself->sgid == IDLE) | |
21 { | |
22 ow = FUSELAGE_W; | |
23 oh = FUSELAGE_H; | |
24 oz = FUSELAGE_Z; | |
25 } | |
26 else if (oneself->sgid == E_PLANE) | |
27 { | |
28 ow = E_PLANE_W; | |
29 oh = E_PLANE_H; | |
30 oz = E_PLANE_Z; | |
31 } | |
32 else if(oneself->sgid == BULEBULLET) | |
33 { | |
34 ow = BULLTE_W; | |
35 oh = BULLTE_H; | |
36 oz = BULLTE_Z; | |
37 } | |
38 if(partner->sgid == IDLE) | |
39 { | |
40 pw = FUSELAGE_W; | |
41 ph = FUSELAGE_H; | |
42 pz = FUSELAGE_Z; | |
43 } | |
44 else if(partner->sgid == E_PLANE) | |
45 { | |
46 pw = E_PLANE_W; | |
47 ph = E_PLANE_H; | |
48 pz = E_PLANE_Z; | |
49 } | |
50 else if(partner->sgid == BULEBULLET) | |
51 { | |
52 pw = BULLTE_W; | |
53 ph = BULLTE_H; | |
54 pz = BULLTE_Z; | |
55 } | |
56 | |
57 | |
58 int ox_min = (int)(oneself->xyz[0] + oneself->c_xyz[0] - ow/2); | |
59 int oy_min = (int)(oneself->xyz[1] + oneself->c_xyz[1] - oh/2); | |
60 int oz_min = (int)(oneself->xyz[2] + oneself->c_xyz[2] - oz/2); | |
61 | |
62 int ox_max = (int)(oneself->xyz[0] + oneself->c_xyz[0] + ow/2); | |
63 int oy_max = (int)(oneself->xyz[1] + oneself->c_xyz[1] + oh/2); | |
64 int oz_max = (int)(oneself->xyz[2] + oneself->c_xyz[2] + oz/2); | |
65 | |
66 int px_min = (int)(partner->xyz[0] + partner->c_xyz[0] - pw/2); | |
67 int py_min = (int)(partner->xyz[1] + partner->c_xyz[1] - ph/2); | |
68 int pz_min = (int)(partner->xyz[2] + partner->c_xyz[2] - pz/2); | |
69 | |
70 int px_max = (int)(partner->xyz[0] + partner->c_xyz[0] + pw/2); | |
71 int py_max = (int)(partner->xyz[1] + partner->c_xyz[1] + ph/2); | |
72 int pz_max = (int)(partner->xyz[2] + partner->c_xyz[2] + pz/2); | |
73 | |
74 if(ox_max < px_min || px_max < ox_min || oy_max < py_min || py_max < oy_min || oz_max < pz_min || pz_max < oz_min) | |
75 { | |
76 } else { | |
77 return HIT; | |
78 } | |
79 return 0; | |
80 } |