File: PrimitiveRule.h

package info (click to toggle)
structure-synth 1.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,072 kB
  • ctags: 1,176
  • sloc: cpp: 7,070; python: 167; makefile: 66; lisp: 25
file content (54 lines) | stat: -rw-r--r-- 1,621 bytes parent folder | download
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
47
48
49
50
51
52
53
54
#pragma once

#include "Rule.h"

namespace StructureSynth {
	namespace Model {	

		/// These are the built-in primitives,
		/// for drawing boxes, spheres and other simple geometric shapes.
		class PrimitiveRule : public Rule {
			public:
				enum PrimitiveType { Box, Sphere, Dot, Grid, Cylinder, Line, Mesh, Template, Other } ;
				
				PrimitiveRule(PrimitiveType type);
				virtual void apply(Builder* builder) const;
	
				/// Returns a list over rules that this rule references.
				/// (Empty for all PrimitiveRules!)
				virtual QList<RuleRef*> getRuleRefs() const { return QList<RuleRef*>(); }

				/// 'class' is an identifier used for distinguishing between
				/// different forms of the the same PrimiteType.
				/// This is used together with Template Renderers.
				///
				/// For instance 'box::metal' will be parsed in to a 'box' primitive with a 'metal' class identifier.
				void setClass(QString classID) { this->classID = classID; }
				QString getClass() { return classID; }
		    protected:
			    QString classID;
			private:
				PrimitiveType type;
				
		};

		/// Triangle rules are special, since they have explicit coordinate representation.
		class TriangleRule : public PrimitiveRule {
			public:
				
				TriangleRule(SyntopiaCore::Math::Vector3f p1,
					          SyntopiaCore::Math::Vector3f p2,
							   SyntopiaCore::Math::Vector3f p3);

				virtual void apply(Builder* builder) const;
	
			private:
				SyntopiaCore::Math::Vector3f p1;
				SyntopiaCore::Math::Vector3f p2;
				SyntopiaCore::Math::Vector3f p3;
				
		};

	}
}