37 : terrain(terr), rect(r)
46 loc = (p1 + p2) * 0.5;
62 if (ty > patch->
Height()-1)
66 int tx =
rect.
x + (PATCH_SIZE-1 - j);
71 if (tx > patch->
Width()-1)
72 tx = patch->
Width()-1;
106 int npolys = detail_size * detail_size * 2;
118 strcpy_s(mtl->
name,
"Terrain Apron");
133 ZeroMemory(vset->
loc, nverts *
sizeof(
Vec3));
134 ZeroMemory(vset->
diffuse, nverts *
sizeof(DWORD));
135 ZeroMemory(vset->
specular, nverts *
sizeof(DWORD));
136 ZeroMemory(vset->
tu, nverts *
sizeof(
float));
137 ZeroMemory(vset->
tv, nverts *
sizeof(
float));
138 ZeroMemory(vset->
rw, nverts *
sizeof(
float));
143 float* pTu = vset->
tu;
144 float* pTv = vset->
tv;
145 double dt = (1.0/3.0) / (double) detail_size;
146 double tu0 = (double)
rect.
x /
rect.
w / 3.0 + (1.0/3.0);
149 for (i = 0; i < ds1; i++) {
150 for (j = 0; j < ds1; j++) {
155 *pTu++ = (float) (tu0 - j*dt);
156 *pTv++ = (float) (tv0 + i*dt);
161 for (i = 0; i <
npolys; i++) {
173 for (i = 0; i < detail_size; i++) {
174 for (j = 0; j < detail_size; j++) {
177 p->
verts[0] = (ds1 * (i ) + (j ));
178 p->
verts[1] = (ds1 * (i ) + (j+1));
179 p->
verts[2] = (ds1 * (i+1) + (j+1));
183 p->
verts[0] = (ds1 * (i ) + (j ));
184 p->
verts[1] = (ds1 * (i+1) + (j+1));
185 p->
verts[2] = (ds1 * (i+1) + (j ));
190 for (i = 0; i <
npolys; i++) {
212 for (i = 0; i < ds1; i++) {
213 for (j = 0; j < ds1; j++) {
214 vset->
nrm[i*ds1+j] = normal;
249 DWORD aval = ambient.
Value();
251 for (
int i = 0; i <
nverts; i++) {
256 bool eclipsed =
false;
270 for (
int i = 0; i <
nverts; i++) {
275 double gain = vl * nrm;
278 val = light->
Intensity() * (0.85 * gain);
330 Point sun = Q + w*len;