File: Cone.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 (46 lines) | stat: -rw-r--r-- 1,340 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
46
//#ident "$Id: Cone.cpp,v 1.8 2003/05/12 12:17:58 rzr Exp $"
/***************************************************************************
                          Cone.cpp  -  description
                             -------------------
    begin                : Wed Jan 26 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

#include "Private.h"
#include "Cone.h"
#include "Polygon.h"

Cone::Cone(float fSize, int sides, float fR, float fG, float fB, float fA) : Shape3D(8+1, 8+1) {
	if (sides < 3) sides = 3;
	Polygon3D* p;
	// Top vertex.
	this->add(0, fSize/2, 0);
	// Ring of vertices.
	for (float a=0; a<sides; ++a)	{
		this->add( EMath::emSin(a/sides)*fSize/2, -fSize/2 , EMath::emCos(a/sides)*fSize/2,
							 fR, fG, fB, fA, 0.0f, 0.0f);
	}	
	// The ring of polygons.
	{ for (int a=1; a<sides; ++a)	{
		p = new Polygon3D(this, 3);
		p->add(0);
		p->add(a+1);
		p->add(a);
		this->add(p);
	} }
	// the last one
	p = new Polygon3D(this, 3);
	p->add(0);
	p->add(1);
	p->add(sides);
	this->add(p);
	// The bottom of the cone.
	p = new Polygon3D(this, sides);
	{ for (int a=0; a<sides; ++a) {
		p->add(a+1);
	} }
	this->add(p);
	
	this->countNormals();
}