yyparse() now a friend function to Scene, light constructors not taking position arguments any more

git-svn-id: svn://anubis/fart/trunk@104 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-02-12 03:56:09 +00:00
1 parent c136bda827
commit 6f2851f279
8 files changed
+75 -10

No files matched your search

+1
View File
@@ -38,6 +38,7 @@ camera return CAMERA;
diffuse return DIFFUSE;
height return HEIGHT;
intersect return INTERSECT;
light return LIGHT;
look_at return LOOKAT;
material return MATERIAL;
multisample return MULTISAMPLE;
+60 -1
View File
@@ -45,11 +45,14 @@ enum Node_Type
{
Node_Shape = 0x42001, /* don't clash with bison token namespace */
Node_Camera,
Node_Options
Node_Options,
Node_Light
};
#define YYSTYPE refptr<Node>
static Scene * g_scene;
%}
%token PLUS;
@@ -85,6 +88,7 @@ enum Node_Type
%token DIFFUSE;
%token HEIGHT;
%token INTERSECT;
%token LIGHT;
%token LOOKAT;
%token MATERIAL;
%token MULTISAMPLE;
@@ -111,6 +115,18 @@ scene: SCENE LCURLY scene_items RCURLY {
{
/* process this scene item */
refptr<Node> thisNode = node->the_Node;
switch (thisNode->type)
{
case Node_Shape:
g_scene->m_shapes.push_back(thisNode->the_Shape);
break;
case Node_Camera:
break;
case Node_Light:
break;
case Node_Options:
break;
}
node = node->the_tail;
}
}
@@ -172,6 +188,47 @@ camera_item: POSITION vector {
intersect: INTERSECT LCURLY boolean_items RCURLY
;
light: LIGHT LCURLY light_items RCURLY {
$$ = new Node();
refptr<Light> light = new Light();
refptr<Node> node = $3;
while ( ! node.isNull() )
{
switch (node->type)
{
case POSITION:
break;
}
node = node->the_tail;
}
}
;
light_items: /* empty */
| light_item light_items {
$$ = new Node();
$$->the_Node = $1;
$$->the_tail = $2;
}
;
light_item: POSITION vector {
$$ = new Node();
$$->type = POSITION;
$$->the_Vector = $2->the_Vector;
}
| DIFFUSE vector {
$$ = new Node();
$$->type = DIFFUSE;
$$->the_Color = new Color(* $2->the_Vector);
}
| SPECULAR vector {
$$ = new Node();
$$->type = SPECULAR;
$$->the_Color = new Color(* $2->the_Vector);
}
;
material: MATERIAL LCURLY material_items RCURLY {
$$ = new Node();
refptr<Material> material = new Material();
@@ -302,6 +359,7 @@ scene_items: /* empty */
scene_item: camera { $$ = $1; $$->type = Node_Camera; }
| shape { $$ = $1; $$->type = Node_Shape; }
| options { $$ = $1; $$->type = Node_Options; }
| light { $$ = $1; $$->type = Node_Light; }
;
shape: plane { $$ = $1; }
@@ -346,6 +404,7 @@ vector: LESS number COMMA number COMMA number GREATER {
int Scene::parse(const char * fileName)
{
g_scene = this;
yyin = fopen(fileName, "r");
if (yyin == NULL)
{