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
79
80
81
82
83
|
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
79
80
81
82
83
|
-
-
+
+
-
+
-
-
+
+
+
-
+
+
-
+
-
+
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
+
|
static const int FIRSTMDL = 20;
void
delayedload(MD2 *m)
{
if (!m.loaded) {
OFString *path = [OFString
stringWithFormat:@"packages/models/%@", m.loadname];
OFString *path = [OFString stringWithFormat:
@"packages/models/%@", m.loadname];
OFIRI *baseIRI = [Cube.sharedInstance.gameDataIRI
IRIByAppendingPathComponent:path];
IRIByAppendingPathComponent: path];
OFIRI *IRI1 = [baseIRI IRIByAppendingPathComponent:@"tris.md2"];
if (![m loadWithIRI:IRI1])
OFIRI *IRI1 = [baseIRI
IRIByAppendingPathComponent: @"tris.md2"];
if (![m loadWithIRI: IRI1])
fatal(@"loadmodel: %@", IRI1.string);
OFIRI *IRI2 = [baseIRI IRIByAppendingPathComponent:@"skin.jpg"];
OFIRI *IRI2 = [baseIRI
IRIByAppendingPathComponent: @"skin.jpg"];
int xs, ys;
installtex(FIRSTMDL + m.mdlnum, IRI2, &xs, &ys, false);
m.loaded = true;
}
}
MD2 *
loadmodel(OFString *name)
{
static int modelnum = 0;
MD2 *m = mdllookup[name];
if (m != nil)
return m;
m = [MD2 md2];
m.mdlnum = modelnum++;
m.mmi = [MapModelInfo infoWithRad:2 h:2 zoff:0 snap:0 name:@""];
m.mmi = [MapModelInfo infoWithRad: 2 h: 2 zoff: 0 snap: 0 name: @""];
m.loadname = name;
if (mdllookup == nil)
mdllookup = [[OFMutableDictionary alloc] init];
mdllookup[name] = m;
return m;
}
COMMAND(mapmodel, ARG_5STR,
COMMAND(mapmodel, ARG_5STR, ^ (OFString *rad, OFString *h, OFString *zoff,
^(OFString *rad, OFString *h, OFString *zoff, OFString *snap,
OFString *name) {
OFString *snap, OFString *name) {
MD2 *m =
loadmodel([name stringByReplacingOccurrencesOfString:@"\\"
withString:@"/"]);
m.mmi = [MapModelInfo infoWithRad:rad.cube_intValue
h:h.cube_intValue
zoff:zoff.cube_intValue
snap:snap.cube_intValue
name:m.loadname];
MD2 *m = loadmodel([name stringByReplacingOccurrencesOfString: @"\\"
withString: @"/"]);
m.mmi = [MapModelInfo infoWithRad: rad.cube_intValue
h: h.cube_intValue
zoff: zoff.cube_intValue
snap: snap.cube_intValue
name: m.loadname];
if (mapmodels == nil)
mapmodels = [[OFMutableArray alloc] init];
if (mapmodels == nil)
mapmodels = [[OFMutableArray alloc] init];
[mapmodels addObject:m];
})
[mapmodels addObject: m];
})
COMMAND(mapmodelreset, ARG_NONE, ^{
COMMAND(mapmodelreset, ARG_NONE, ^ {
[mapmodels removeAllObjects];
})
MapModelInfo *
getmminfo(int i)
{
return i < mapmodels.count ? mapmodels[i].mmi : nil;
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
|
int xs, ys;
glBindTexture(GL_TEXTURE_2D,
tex ? lookuptexture(tex, &xs, &ys) : FIRSTMDL + m.mdlnum);
int ix = (int)position.x;
int iy = (int)position.z;
OFColor *light = [OFColor colorWithRed:1 green:1 blue:1 alpha:1];
OFColor *light = OFColor.white;
if (!OUTBORD(ix, iy)) {
struct sqr *s = S(ix, iy);
float ll = 256.0f; // 0.96f;
float of = 0.0f; // 0.1f;
light = [OFColor colorWithRed:s->r / ll + of
green:s->g / ll + of
blue:s->b / ll + of
alpha:1];
light = [OFColor colorWithRed: s->r / ll + of
green: s->g / ll + of
blue: s->b / ll + of
alpha: 1];
}
if (teammate) {
float red, green, blue;
[light getRed:&red green:&green blue:&blue alpha:NULL];
light = [OFColor colorWithRed:red * 0.6f
green:green * 0.7f
blue:blue * 1.2f
alpha:1];
[light getRed: &red green: &green blue: &blue alpha: NULL];
light = [OFColor colorWithRed: red * 0.6f
green: green * 0.7f
blue: blue * 1.2f
alpha: 1];
}
[m renderWithLight:light
frame:frame
range:range
position:position
yaw:yaw
pitch:pitch
scale:scale
speed:speed
snap:snap
basetime:basetime];
[m renderWithLight: light
frame: frame
range: range
position: position
yaw: yaw
pitch: pitch
scale: scale
speed: speed
snap: snap
basetime: basetime];
}
|