updating parser nodes, introducing conflicts, still not compiling
git-svn-id: svn://anubis/fart/trunk@108 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
9849ba06b5
commit
4d5faf8362
@ -5,6 +5,9 @@ using namespace std;
|
|||||||
|
|
||||||
void Node::addChildren(refptr<Node> other)
|
void Node::addChildren(refptr<Node> other)
|
||||||
{
|
{
|
||||||
|
if (other.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
for (typeof(other.m_children)::const_iterator it = other.m_children.begin();
|
for (typeof(other.m_children)::const_iterator it = other.m_children.begin();
|
||||||
it != other.m_children.end();
|
it != other.m_children.end();
|
||||||
it++)
|
it++)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#ifndef NODES_H
|
#ifndef NODES_H
|
||||||
#define NODES_H NODES_H
|
#define NODES_H NODES_H
|
||||||
|
|
||||||
|
#include "util/Vector.h"
|
||||||
|
#include "main/Material.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Node
|
class Node
|
||||||
@ -17,13 +19,62 @@ class Node
|
|||||||
return refptr<Material>(NULL);
|
return refptr<Material>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual double getNumber() { return 0.0; }
|
||||||
|
|
||||||
|
virtual refptr<Vector> getVector()
|
||||||
|
{
|
||||||
|
return refptr<Vector>(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector< refptr<Node> > m_children;
|
std::vector< refptr<Node> > m_children;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SceneItemsNode : public Node
|
class CameraNode : public Node
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ItemsNode : public Node
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class LightNode : public Node
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class MaterialNode : public Node
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class NumberNode : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
double getNumber() { return m_number; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class RadiusNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RadiusNode(double radius) { m_radius = radius; }
|
||||||
|
double getNumber() { return m_radius; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
double m_radius;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ShapeNode : public Node
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class VectorNode : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VectorNode(refptr<Vector> vector) { m_vector = vector; }
|
||||||
|
refptr<Vector> getVector() { return m_vector; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
refptr<Vector> m_vector;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ multisample return MULTISAMPLE;
|
|||||||
options return OPTIONS;
|
options return OPTIONS;
|
||||||
plane return PLANE;
|
plane return PLANE;
|
||||||
position return POSITION;
|
position return POSITION;
|
||||||
|
radius return RADIUS;
|
||||||
reflectance return REFLECTANCE;
|
reflectance return REFLECTANCE;
|
||||||
scene return SCENE;
|
scene return SCENE;
|
||||||
shininess return SHININESS;
|
shininess return SHININESS;
|
||||||
|
@ -74,6 +74,7 @@ static Scene * g_scene;
|
|||||||
%token OPTIONS;
|
%token OPTIONS;
|
||||||
%token PLANE;
|
%token PLANE;
|
||||||
%token POSITION;
|
%token POSITION;
|
||||||
|
%token RADIUS;
|
||||||
%token REFLECTANCE;
|
%token REFLECTANCE;
|
||||||
%token SCENE;
|
%token SCENE;
|
||||||
%token SHININESS;
|
%token SHININESS;
|
||||||
@ -327,18 +328,23 @@ plane: PLANE LPAREN vector COMMA number RPAREN LCURLY plane_items RCURLY {
|
|||||||
plane_items: shape_items { $$ = $1; }
|
plane_items: shape_items { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
radius: RADIUS number {
|
||||||
|
$$ = new RadiusNode($2->getNumber());
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
scene_items: /* empty */
|
scene_items: /* empty */
|
||||||
| scene_item scene_items {
|
| scene_item scene_items {
|
||||||
$$ = new SceneItemsNode();
|
$$ = new ItemsNode();
|
||||||
$$->addChild($1);
|
$$->addChild($1);
|
||||||
$$->addChildren($2);
|
$$->addChildren($2);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
scene_item: camera { $$ = $1; $$->type = Node_Camera; }
|
scene_item: camera { $$ = $1; }
|
||||||
| shape { $$ = $1; $$->type = Node_Shape; }
|
| shape { $$ = $1; }
|
||||||
| options { $$ = $1; $$->type = Node_Options; }
|
| options { $$ = $1; }
|
||||||
| light { $$ = $1; $$->type = Node_Light; }
|
| light { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
shape: plane { $$ = $1; }
|
shape: plane { $$ = $1; }
|
||||||
@ -350,17 +356,39 @@ shape: plane { $$ = $1; }
|
|||||||
;
|
;
|
||||||
|
|
||||||
shape_items: /* empty */
|
shape_items: /* empty */
|
||||||
|
| shape_item shape_items {
|
||||||
|
$$ = new ItemsNode();
|
||||||
|
$$->addChild($1);
|
||||||
|
$$->addChildren($2);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
shape_item:
|
||||||
| material { $$ = $1; }
|
| material { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
sphere: SPHERE LPAREN number RPAREN LCURLY sphere_items RCURLY {
|
sphere: SPHERE LCURLY sphere_items RCURLY {
|
||||||
Sphere * sphere = new Sphere(*($3->the_double));
|
Sphere * sphere = new Sphere(*($3->the_double));
|
||||||
$$ = new Node();
|
$$ = new SphereNode();
|
||||||
$$->the_Shape = sphere;
|
$$->the_Shape = sphere;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
sphere_items: shape_items { $$ = $1; }
|
sphere_items: /* empty */
|
||||||
|
| sphere_item sphere_items {
|
||||||
|
$$ = new ItemsNode();
|
||||||
|
$$->addChild($1);
|
||||||
|
$$->addChildren($2);
|
||||||
|
}
|
||||||
|
| shape_item sphere_items {
|
||||||
|
$$ = new ItemsNode();
|
||||||
|
$$->addChild($1);
|
||||||
|
$$->addChildren($2);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
sphere_item: radius { $$ = $1; }
|
||||||
|
| shape_item { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
subtract: SUBTRACT LCURLY boolean_items RCURLY
|
subtract: SUBTRACT LCURLY boolean_items RCURLY
|
||||||
@ -370,12 +398,11 @@ union: UNION LCURLY boolean_items RCURLY
|
|||||||
;
|
;
|
||||||
|
|
||||||
vector: LESS number COMMA number COMMA number GREATER {
|
vector: LESS number COMMA number COMMA number GREATER {
|
||||||
Vector * ptr = new Vector();
|
refptr<Vector> vector = new Vector();
|
||||||
(*ptr)[0] = * $2->the_double;
|
(*vector)[0] = * $2->getNumber();
|
||||||
(*ptr)[1] = * $4->the_double;
|
(*vector)[1] = * $4->getNumber();
|
||||||
(*ptr)[2] = * $6->the_double;
|
(*vector)[2] = * $6->getNumber();
|
||||||
$$ = new Node();
|
$$ = new VectorNode(vector);
|
||||||
$$->the_Vector = ptr;
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user