1 /***************************************************************************
2                           Grid.cpp  -  description
3                              -------------------
4     begin                : Tue Feb 8 2000
5     copyright            : (C) 2000 by Henrik Enqvist
6     email                : henqvist@excite.com
7  ***************************************************************************/
8 
9 #include "Private.h"
10 #include "Grid.h"
11 #include "Polygon.h"
12 
Grid(EmTexture * texture,float sizex,float sizey,int step,float bmStep,float fR,float fG,float fB,float fA)13 Grid::Grid(EmTexture* texture, float sizex, float sizey, int step, float bmStep,
14 		float fR, float fG, float fB, float fA) : Shape3D((step+1)*(step+1), step*step) {
15 	Polygon3D * poly;
16 
17 	sizex /= step;
18 	sizey /= step;
19 
20 	{ for (int a=0; a<=step; a++) {
21 		for (int b=0; b<=step; b++) {
22 			this->add( a*sizex - step*sizex*0.5, 0, -b*sizey + step*sizey*0.5,
23 								 fR, fG, fB, fA, b*bmStep, a*bmStep);
24 		}
25 	} }
26 
27 	{ for (int a=0; a<step; a++) {
28 		for (int b=0; b<step; b++) {
29 			poly = new Polygon3D(this, 4);
30 // 			poly->add(a + b*(step+1),					a*bmStep, b*bmStep, 				fR, fG, fB, fA);
31 // 			poly->add((a+1) + b*(step+1),			(a+1)*bmStep, b*bmStep, 		fR, fG, fB, fA);
32 // 			poly->add((a+1) + (b+1)*(step+1),	(a+1)*bmStep, (b+1)*bmStep, fR, fG, fB, fA);
33 // 			poly->add(a + (b+1)*(step+1),			a*bmStep, (b+1)*bmStep, 		fR, fG, fB, fA);
34 			poly->add(a + b*(step+1));
35 			poly->add((a+1) + b*(step+1));
36 			poly->add((a+1) + (b+1)*(step+1));
37 			poly->add(a + (b+1)*(step+1));
38 			this->add(poly);
39 		}
40 	} }
41 
42 	this->setTexture(texture);
43 	this->countNormals();
44 }
45 
46