removed knowledge of domain types from parser, removed process() from Node, added a global refptr<Node> object, took parse(fileName) out of Scene class
git-svn-id: svn://anubis/fart/trunk@123 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
a8e898e445
commit
f3e522262b
@ -13,6 +13,9 @@
|
|||||||
#include "shapes/Shape.h"
|
#include "shapes/Shape.h"
|
||||||
#include "PointLight.h"
|
#include "PointLight.h"
|
||||||
#include "Lighting.h"
|
#include "Lighting.h"
|
||||||
|
|
||||||
|
#include "parser/nodes.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Scene::Scene(const map<string, const char *> & options,
|
Scene::Scene(const map<string, const char *> & options,
|
||||||
@ -116,6 +119,10 @@ void Scene::load(const char * filename)
|
|||||||
m_lights.push_back(light);
|
m_lights.push_back(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parse(refptr<Node> node)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Scene::render()
|
void Scene::render()
|
||||||
{
|
{
|
||||||
if (m_verbose)
|
if (m_verbose)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "util/Color.h"
|
#include "util/Color.h"
|
||||||
#include "shapes/Shape.h"
|
#include "shapes/Shape.h"
|
||||||
#include "Light.h"
|
#include "Light.h"
|
||||||
|
#include "parser/nodes.h"
|
||||||
|
|
||||||
#define SCENE_MAX_TRANSPARENT_HITS 8
|
#define SCENE_MAX_TRANSPARENT_HITS 8
|
||||||
#define SCENE_TRANSPARENCY_THRESHOLD 0.01
|
#define SCENE_TRANSPARENCY_THRESHOLD 0.01
|
||||||
@ -39,15 +40,13 @@ class Scene
|
|||||||
void setAmbientLight(const Color & al) { m_ambient_light = al; }
|
void setAmbientLight(const Color & al) { m_ambient_light = al; }
|
||||||
Transform & getTransform() { return m_transform; }
|
Transform & getTransform() { return m_transform; }
|
||||||
|
|
||||||
friend int yyparse();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* private methods */
|
/* private methods */
|
||||||
void load(const char * filename);
|
void load(const char * filename);
|
||||||
void renderPixel(int x, int y, unsigned char * pixel);
|
void renderPixel(int x, int y, unsigned char * pixel);
|
||||||
Color traceRay(const Ray & ray);
|
Color traceRay(const Ray & ray);
|
||||||
std::vector<ShapeDistance> getRayHits(const Ray & ray);
|
std::vector<ShapeDistance> getRayHits(const Ray & ray);
|
||||||
int parse(const char * fileName);
|
void parse(refptr<Node> node);
|
||||||
|
|
||||||
/* rendering parameters */
|
/* rendering parameters */
|
||||||
int m_width;
|
int m_width;
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#include "util/refptr.h"
|
#include "util/refptr.h"
|
||||||
#include "util/Vector.h"
|
#include "util/Vector.h"
|
||||||
#include "main/Material.h"
|
|
||||||
#include "main/Scene.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Node
|
class Node
|
||||||
@ -15,13 +13,7 @@ class Node
|
|||||||
void addChild(refptr<Node> child) { m_children.push_back(child); }
|
void addChild(refptr<Node> child) { m_children.push_back(child); }
|
||||||
void addChildren(refptr<Node> other);
|
void addChildren(refptr<Node> other);
|
||||||
|
|
||||||
virtual void process(refptr<Scene> scene) {}
|
|
||||||
|
|
||||||
virtual int getInteger() { return 0; }
|
virtual int getInteger() { return 0; }
|
||||||
virtual refptr<Material> getMaterial()
|
|
||||||
{
|
|
||||||
return refptr<Material>(NULL);
|
|
||||||
}
|
|
||||||
virtual double getNumber() { return 0.0; }
|
virtual double getNumber() { return 0.0; }
|
||||||
virtual refptr<Vector> getVector()
|
virtual refptr<Vector> getVector()
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
#ifndef PARSER_H
|
#ifndef PARSER_H
|
||||||
#define PARSER_H PARSER_H
|
#define PARSER_H PARSER_H
|
||||||
|
|
||||||
|
#include "nodes.h"
|
||||||
|
#include "util/refptr.h"
|
||||||
|
|
||||||
#define YYSTYPE refptr<Node>
|
#define YYSTYPE refptr<Node>
|
||||||
|
|
||||||
|
extern YYSTYPE parsed_scene_node;
|
||||||
|
|
||||||
|
int parse(const char * fileName);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,11 +3,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "main/Scene.h"
|
|
||||||
#include "main/Material.h"
|
|
||||||
#include "util/Vector.h"
|
#include "util/Vector.h"
|
||||||
#include "util/refptr.h"
|
#include "util/refptr.h"
|
||||||
#include "shapes/Shape.h" /* includes all shape types */
|
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -26,7 +23,7 @@ int yywrap()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Scene * g_scene;
|
refptr<Node> parsed_scene_node;
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@ -91,6 +88,7 @@ static Scene * g_scene;
|
|||||||
scene: SCENE LCURLY scene_items RCURLY {
|
scene: SCENE LCURLY scene_items RCURLY {
|
||||||
$$ = new SceneNode();
|
$$ = new SceneNode();
|
||||||
$$->addChildren($3);
|
$$->addChildren($3);
|
||||||
|
parsed_scene_node = $$;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -389,9 +387,8 @@ vector: LESS number COMMA number COMMA number GREATER {
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
int Scene::parse(const char * fileName)
|
int parse(const char * fileName)
|
||||||
{
|
{
|
||||||
g_scene = this;
|
|
||||||
yyin = fopen(fileName, "r");
|
yyin = fopen(fileName, "r");
|
||||||
if (yyin == NULL)
|
if (yyin == NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user