adding required arguments to shape constructors in scene description language
git-svn-id: svn://anubis/fart/trunk@95 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
0181e82653
commit
2e82f9e2ea
@ -43,7 +43,6 @@ 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;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "main/Scene.h"
|
#include "main/Scene.h"
|
||||||
@ -34,6 +35,7 @@ class Node
|
|||||||
int type;
|
int type;
|
||||||
double * the_double;
|
double * the_double;
|
||||||
Material * the_Material;
|
Material * the_Material;
|
||||||
|
Shape * the_Shape;
|
||||||
Vector * the_Vector;
|
Vector * the_Vector;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,7 +83,6 @@ 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;
|
||||||
@ -106,11 +107,10 @@ boolean_items_more: /* empty */
|
|||||||
| material boolean_items_more
|
| material boolean_items_more
|
||||||
;
|
;
|
||||||
|
|
||||||
box: BOX LCURLY box_items RCURLY
|
box: BOX LPAREN vector RPAREN LCURLY box_items RCURLY
|
||||||
;
|
;
|
||||||
|
|
||||||
box_items: shape_items
|
box_items: shape_items
|
||||||
| SIZE vector box_items
|
|
||||||
;
|
;
|
||||||
|
|
||||||
camera: CAMERA LCURLY camera_items RCURLY
|
camera: CAMERA LCURLY camera_items RCURLY
|
||||||
@ -155,11 +155,17 @@ number: DEC_NUMBER {
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
plane: PLANE LCURLY plane_items RCURLY
|
plane: PLANE LPAREN vector COMMA number RPAREN LCURLY plane_items RCURLY {
|
||||||
|
Plane * plane = new Plane((*($3->the_Vector))[0],
|
||||||
|
(*($3->the_Vector))[1],
|
||||||
|
(*($3->the_Vector))[2],
|
||||||
|
*($5->the_double));
|
||||||
|
$$ = new Node();
|
||||||
|
$$->the_Shape = plane;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
plane_items: shape_items
|
plane_items: shape_items
|
||||||
| POSITION vector COMMA number plane_items
|
|
||||||
;
|
;
|
||||||
|
|
||||||
scene_spec: SCENE LCURLY scene_items RCURLY
|
scene_spec: SCENE LCURLY scene_items RCURLY
|
||||||
@ -169,27 +175,26 @@ scene_items: /* empty */
|
|||||||
| scene_item scene_items
|
| scene_item scene_items
|
||||||
;
|
;
|
||||||
|
|
||||||
scene_item: camera
|
scene_item: camera { $$ = $1; }
|
||||||
| shape
|
| shape { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
shape: plane
|
shape: plane { $$ = $1; }
|
||||||
| sphere
|
| sphere { $$ = $1; }
|
||||||
| box
|
| box { $$ = $1; }
|
||||||
| union
|
| union { $$ = $1; }
|
||||||
| intersect
|
| intersect { $$ = $1; }
|
||||||
| subtract
|
| subtract { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
shape_items: /* empty */
|
shape_items: /* empty */
|
||||||
| material
|
| material { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
sphere: SPHERE LCURLY sphere_items RCURLY
|
sphere: SPHERE LPAREN number RPAREN LCURLY sphere_items RCURLY
|
||||||
;
|
;
|
||||||
|
|
||||||
sphere_items: shape_items
|
sphere_items: shape_items
|
||||||
| RADIUS number sphere_items
|
|
||||||
;
|
;
|
||||||
|
|
||||||
subtract: SUBTRACT LCURLY boolean_items RCURLY
|
subtract: SUBTRACT LCURLY boolean_items RCURLY
|
||||||
@ -227,6 +232,7 @@ Node::Node()
|
|||||||
type = -1;
|
type = -1;
|
||||||
the_double = NULL;
|
the_double = NULL;
|
||||||
the_Material = NULL;
|
the_Material = NULL;
|
||||||
|
the_Shape = NULL;
|
||||||
the_Vector = NULL;
|
the_Vector = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,6 +242,8 @@ Node::~Node()
|
|||||||
delete the_double;
|
delete the_double;
|
||||||
if (the_Material != NULL)
|
if (the_Material != NULL)
|
||||||
delete the_Material;
|
delete the_Material;
|
||||||
|
if (the_Shape != NULL)
|
||||||
|
delete the_Shape;
|
||||||
if (the_Vector != NULL)
|
if (the_Vector != NULL)
|
||||||
delete the_Vector;
|
delete the_Vector;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user