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)
|
||||
{
|
||||
if (other.isNull())
|
||||
return;
|
||||
|
||||
for (typeof(other.m_children)::const_iterator it = other.m_children.begin();
|
||||
it != other.m_children.end();
|
||||
it++)
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef NODES_H
|
||||
#define NODES_H NODES_H
|
||||
|
||||
#include "util/Vector.h"
|
||||
#include "main/Material.h"
|
||||
#include <vector>
|
||||
|
||||
class Node
|
||||
@ -17,13 +19,62 @@ class Node
|
||||
return refptr<Material>(NULL);
|
||||
}
|
||||
|
||||
virtual double getNumber() { return 0.0; }
|
||||
|
||||
virtual refptr<Vector> getVector()
|
||||
{
|
||||
return refptr<Vector>(NULL);
|
||||
}
|
||||
|
||||
protected:
|
||||
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
|
||||
|
||||
|
@ -45,6 +45,7 @@ multisample return MULTISAMPLE;
|
||||
options return OPTIONS;
|
||||
plane return PLANE;
|
||||
position return POSITION;
|
||||
radius return RADIUS;
|
||||
reflectance return REFLECTANCE;
|
||||
scene return SCENE;
|
||||
shininess return SHININESS;
|
||||
|
@ -74,6 +74,7 @@ static Scene * g_scene;
|
||||
%token OPTIONS;
|
||||
%token PLANE;
|
||||
%token POSITION;
|
||||
%token RADIUS;
|
||||
%token REFLECTANCE;
|
||||
%token SCENE;
|
||||
%token SHININESS;
|
||||
@ -327,18 +328,23 @@ plane: PLANE LPAREN vector COMMA number RPAREN LCURLY plane_items RCURLY {
|
||||
plane_items: shape_items { $$ = $1; }
|
||||
;
|
||||
|
||||
radius: RADIUS number {
|
||||
$$ = new RadiusNode($2->getNumber());
|
||||
}
|
||||
;
|
||||
|
||||
scene_items: /* empty */
|
||||
| scene_item scene_items {
|
||||
$$ = new SceneItemsNode();
|
||||
$$ = new ItemsNode();
|
||||
$$->addChild($1);
|
||||
$$->addChildren($2);
|
||||
}
|
||||
;
|
||||
|
||||
scene_item: camera { $$ = $1; $$->type = Node_Camera; }
|
||||
| shape { $$ = $1; $$->type = Node_Shape; }
|
||||
| options { $$ = $1; $$->type = Node_Options; }
|
||||
| light { $$ = $1; $$->type = Node_Light; }
|
||||
scene_item: camera { $$ = $1; }
|
||||
| shape { $$ = $1; }
|
||||
| options { $$ = $1; }
|
||||
| light { $$ = $1; }
|
||||
;
|
||||
|
||||
shape: plane { $$ = $1; }
|
||||
@ -350,19 +356,41 @@ shape: plane { $$ = $1; }
|
||||
;
|
||||
|
||||
shape_items: /* empty */
|
||||
| material { $$ = $1; }
|
||||
| shape_item shape_items {
|
||||
$$ = new ItemsNode();
|
||||
$$->addChild($1);
|
||||
$$->addChildren($2);
|
||||
}
|
||||
;
|
||||
|
||||
sphere: SPHERE LPAREN number RPAREN LCURLY sphere_items RCURLY {
|
||||
shape_item:
|
||||
| material { $$ = $1; }
|
||||
;
|
||||
|
||||
sphere: SPHERE LCURLY sphere_items RCURLY {
|
||||
Sphere * sphere = new Sphere(*($3->the_double));
|
||||
$$ = new Node();
|
||||
$$ = new SphereNode();
|
||||
$$->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
|
||||
;
|
||||
|
||||
@ -370,12 +398,11 @@ union: UNION LCURLY boolean_items RCURLY
|
||||
;
|
||||
|
||||
vector: LESS number COMMA number COMMA number GREATER {
|
||||
Vector * ptr = new Vector();
|
||||
(*ptr)[0] = * $2->the_double;
|
||||
(*ptr)[1] = * $4->the_double;
|
||||
(*ptr)[2] = * $6->the_double;
|
||||
$$ = new Node();
|
||||
$$->the_Vector = ptr;
|
||||
refptr<Vector> vector = new Vector();
|
||||
(*vector)[0] = * $2->getNumber();
|
||||
(*vector)[1] = * $4->getNumber();
|
||||
(*vector)[2] = * $6->getNumber();
|
||||
$$ = new VectorNode(vector);
|
||||
}
|
||||
;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user