File: Grid.cpp

package info (click to toggle)
pinball 0.3.20230219-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,572 kB
  • sloc: cpp: 15,776; makefile: 1,037; sh: 588; xml: 24
file content (45 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download | duplicates (9)
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
/***************************************************************************
                          Grid.cpp  -  description
                             -------------------
    begin                : Tue Feb 8 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

#include "Private.h"
#include "Grid.h"
#include "Polygon.h"

Grid::Grid(EmTexture* texture, float sizex, float sizey, int step, float bmStep,
		float fR, float fG, float fB, float fA) : Shape3D((step+1)*(step+1), step*step) {
	Polygon3D * poly;

	sizex /= step;
	sizey /= step;
	
	{ for (int a=0; a<=step; a++) {
		for (int b=0; b<=step; b++) {
			this->add( a*sizex - step*sizex*0.5, 0, -b*sizey + step*sizey*0.5,
								 fR, fG, fB, fA, b*bmStep, a*bmStep);
		}
	} }

	{ for (int a=0; a<step; a++) {
		for (int b=0; b<step; b++) {	
			poly = new Polygon3D(this, 4);
// 			poly->add(a + b*(step+1),					a*bmStep, b*bmStep, 				fR, fG, fB, fA);
// 			poly->add((a+1) + b*(step+1),			(a+1)*bmStep, b*bmStep, 		fR, fG, fB, fA);
// 			poly->add((a+1) + (b+1)*(step+1),	(a+1)*bmStep, (b+1)*bmStep, fR, fG, fB, fA);
// 			poly->add(a + (b+1)*(step+1),			a*bmStep, (b+1)*bmStep, 		fR, fG, fB, fA);
			poly->add(a + b*(step+1));
			poly->add((a+1) + b*(step+1));
			poly->add((a+1) + (b+1)*(step+1));
			poly->add(a + (b+1)*(step+1));
			this->add(poly);
		}
	} }

	this->setTexture(texture);
	this->countNormals();
}