File: PrimitiveRule.h

package info (click to toggle)
structure-synth 1.5.0-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,268 kB
  • ctags: 1,966
  • sloc: cpp: 10,209; python: 164; makefile: 71; sh: 15
file content (62 lines) | stat: -rw-r--r-- 1,896 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once

#include "Rule.h"
#include "PrimitiveClass.h"
#include "../../SyntopiaCore/GLEngine/Object3D.h"

namespace StructureSynth {
	namespace Model {	

		using namespace SyntopiaCore::GLEngine;

		/// 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, PrimitiveClass* primitiveClass);
				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(PrimitiveClass* primitiveClass) { this->primitiveClass = primitiveClass; }
				PrimitiveClass* getClass() { return primitiveClass; }

				
		    protected:
			    PrimitiveClass* primitiveClass;
			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,
							     PrimitiveClass* primitiveClass);

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

	}
}