added TranslateNode, RotateNode, and ScaleNode

git-svn-id: svn://anubis/fart/trunk@117 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-02-17 03:25:53 +00:00
parent 2a816c1c1a
commit 0e22a21637
3 changed files with 44 additions and 1 deletions

View File

@ -152,6 +152,26 @@ class ReflectanceNode : public NumberNode
ReflectanceNode(double d) : NumberNode(d) {}
};
class RotateNode : public VectorNode
{
public:
RotateNode(double angle, refptr<Vector> vector)
: VectorNode(vector)
{
m_angle = angle;
}
double getNumber() { return m_angle; }
protected:
double m_angle;
};
class ScaleNode : public VectorNode
{
public:
ScaleNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class SceneNode : public Node
{
};
@ -184,6 +204,12 @@ class SubtractNode : public Node
{
};
class TranslateNode : public VectorNode
{
public:
TranslateNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class UnionNode : public Node
{
};

View File

@ -53,12 +53,15 @@ plane return PLANE;
position return POSITION;
radius return RADIUS;
reflectance return REFLECTANCE;
rotate return ROTATE;
scale return SCALE;
scene return SCENE;
shininess return SHININESS;
size return SIZE;
specular return SPECULAR;
sphere return SPHERE;
subtract return SUBTRACT;
translate return TRANSLATE;
union return UNION;
up return UP;
vfov return VFOV;

View File

@ -26,7 +26,6 @@ int yywrap()
return 1;
}
static Scene * g_scene;
%}
@ -73,12 +72,15 @@ static Scene * g_scene;
%token POSITION;
%token RADIUS;
%token REFLECTANCE;
%token ROTATE;
%token SCALE;
%token SCENE;
%token SHININESS;
%token SIZE;
%token SPECULAR;
%token SPHERE;
%token SUBTRACT;
%token TRANSLATE;
%token UNION;
%token UP;
%token VFOV;
@ -300,6 +302,7 @@ shape_items: /* empty */
;
shape_item: material { $$ = $1; }
| transform { $$ = $1; }
;
sphere: SPHERE LCURLY sphere_items RCURLY {
@ -328,6 +331,17 @@ subtract: SUBTRACT LCURLY shape shape shape_items RCURLY {
}
;
transform: TRANSLATE vector {
$$ = new TranslateNode($2->getVector());
}
| ROTATE number COMMA vector {
$$ = new RotateNode($2->getNumber(), $4->getVector());
}
| SCALE vector {
$$ = new ScaleNode($2->getVector());
}
;
union: UNION LCURLY shape shape shape_items RCURLY {
$$ = new UnionNode();
$$->addChild($3);