added shape definitions into parser, not using them yet

git-svn-id: svn://anubis/fart/trunk@283 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-07-09 16:35:16 +00:00
parent 340742d27b
commit 5308913bdb
4 changed files with 27 additions and 0 deletions

View File

@ -90,6 +90,7 @@ class Scene
/* private data */
std::vector< refptr<Shape> > m_shapes;
std::vector< refptr<Shape> > m_shape_definitions;
std::vector< refptr<Light> > m_lights;
std::stack<Transform> m_transforms;
double m_view_plane_dist;

View File

@ -288,6 +288,18 @@ class SceneNode : public Node
{
};
class ShapeDefinitionNode : public IdentifierNode
{
public:
ShapeDefinitionNode(const std::string & str) : IdentifierNode(str) {}
};
class ShapeRefNode : public IdentifierNode
{
public:
ShapeRefNode(const std::string & str) : IdentifierNode(str) {}
};
class ShininessNode : public NumberNode
{
public:

View File

@ -68,6 +68,7 @@ reflectance return REFLECTANCE;
rotate return ROTATE;
scale return SCALE;
scene return SCENE;
shape return SHAPE;
shininess return SHININESS;
size return SIZE;
specular return SPECULAR;

View File

@ -87,6 +87,7 @@ static refptr<Node> parsed_scene_node;
%token ROTATE;
%token SCALE;
%token SCENE;
%token SHAPE;
%token SHININESS;
%token SIZE;
%token SPECULAR;
@ -435,6 +436,7 @@ scene_item: camera { $$ = $1; }
| light { $$ = $1; }
| transform_block { $$ = $1; }
| material_definition { $$ = $1; }
| shape_definition { $$ = $1; }
;
shape: plane { $$ = $1; }
@ -445,6 +447,16 @@ shape: plane { $$ = $1; }
| intersect { $$ = $1; }
| subtract { $$ = $1; }
| extrude { $$ = $1; }
| shape_ref { $$ = $1; }
;
shape_definition: DEFINE SHAPE IDENTIFIER shape {
$$ = new ShapeDefinitionNode($3->getString());
$$->addChild($4);
}
;
shape_ref: SHAPE IDENTIFIER { $$ = new ShapeRefNode($2->getString()); }
;
shape_item: material { $$ = $1; }
@ -522,6 +534,7 @@ transform_block_items: /* empty */
transform_block_item: transform_block { $$ = $1; }
| light { $$ = $1; }
| shape { $$ = $1; }
| shape_definition { $$ = $1; }
;
union: UNION LCURLY bool_items RCURLY {