added color token to parser for specifying both diffuse and ambient color in a material, added ColorNode, switched color nodes to inherit from VectorNode

git-svn-id: svn://anubis/fart/trunk@163 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-02-28 18:25:12 +00:00
parent 44ba550f68
commit 1924bea5cf
3 changed files with 26 additions and 14 deletions

View File

@ -58,8 +58,10 @@ class VectorNode : public Node
};
class AmbientNode : public Node
class AmbientNode : public VectorNode
{
public:
AmbientNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class BoxNode : public Node
@ -70,8 +72,16 @@ class CameraNode : public Node
{
};
class DiffuseNode : public Node
class ColorNode : public VectorNode
{
public:
ColorNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class DiffuseNode : public VectorNode
{
public:
DiffuseNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class HeightNode : public IntegerNode
@ -201,8 +211,10 @@ class SizeNode : public VectorNode
SizeNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class SpecularNode : public Node
class SpecularNode : public VectorNode
{
public:
SpecularNode(refptr<Vector> vector) : VectorNode(vector) {}
};
class SphereNode : public Node

View File

@ -42,6 +42,7 @@
ambient return AMBIENT;
box return BOX;
camera return CAMERA;
color return COLOR;
diffuse return DIFFUSE;
height return HEIGHT;
intersect return INTERSECT;

View File

@ -61,6 +61,7 @@ static refptr<Node> parsed_scene_node;
%token AMBIENT;
%token BOX;
%token CAMERA;
%token COLOR;
%token DIFFUSE;
%token HEIGHT;
%token INTERSECT;
@ -175,12 +176,10 @@ light_item: POSITION vector {
$$->addChild($2);
}
| DIFFUSE vector {
$$ = new DiffuseNode();
$$->addChild($2);
$$ = new DiffuseNode($2->getVector());
}
| SPECULAR vector {
$$ = new SpecularNode();
$$->addChild($2);
$$ = new SpecularNode($2->getVector());
}
;
@ -198,17 +197,17 @@ material_items: /* empty */
}
;
material_item: AMBIENT vector {
$$ = new AmbientNode();
$$->addChild($2);
material_item: COLOR vector {
$$ = new ColorNode($2->getVector());
}
| AMBIENT vector {
$$ = new AmbientNode($2->getVector());
}
| DIFFUSE vector {
$$ = new DiffuseNode();
$$->addChild($2);
$$ = new DiffuseNode($2->getVector());
}
| SPECULAR vector {
$$ = new SpecularNode();
$$->addChild($2);
$$ = new SpecularNode($2->getVector());
}
| REFLECTANCE number {
$$ = new ReflectanceNode($2->getNumber());