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;
};
}
}
|