Parse the camera section of a scene

This commit is contained in:
Eryn Wells 2014-07-19 21:00:34 -07:00
parent eaabdfddc0
commit 4d5796e6e7
2 changed files with 16 additions and 0 deletions

View file

@ -9,6 +9,7 @@
#include <cassert> #include <cassert>
#include <string> #include <string>
#include "cameraParser.hh"
#include "objectParser.hh" #include "objectParser.hh"
#include "sceneParser.hh" #include "sceneParser.hh"
#include "vectorParser.hh" #include "vectorParser.hh"
@ -31,6 +32,7 @@ void
SceneParser::HandleKeyEvent(const std::string& key) SceneParser::HandleKeyEvent(const std::string& key)
{ {
static const std::map<std::string, Section> sSections = { static const std::map<std::string, Section> sSections = {
{"camera", CameraSection},
{"dimensions", DimensionsSection}, {"dimensions", DimensionsSection},
{"objects", ObjectsSection} {"objects", ObjectsSection}
}; };
@ -49,6 +51,7 @@ SceneParser::HandleValueEvent(yaml_event_t& event)
{ {
switch (mSection) { switch (mSection) {
case CameraSection: case CameraSection:
HandleCameraEvent(event);
break; break;
case DimensionsSection: case DimensionsSection:
HandleDimensionsEvent(event); HandleDimensionsEvent(event);
@ -64,6 +67,18 @@ SceneParser::HandleValueEvent(yaml_event_t& event)
} }
void
SceneParser::HandleCameraEvent(yaml_event_t& event)
{
if (event.type != YAML_MAPPING_START_EVENT) {
assert(event.type != YAML_MAPPING_START_EVENT);
return;
}
GetParsers().push(new CameraParser(GetScene(), GetParsers()));
}
void void
SceneParser::HandleDimensionsEvent(yaml_event_t& event) SceneParser::HandleDimensionsEvent(yaml_event_t& event)
{ {

View file

@ -35,6 +35,7 @@ private:
ObjectsSection, ObjectsSection,
}; };
void HandleCameraEvent(yaml_event_t& event);
void HandleDimensionsEvent(yaml_event_t& event); void HandleDimensionsEvent(yaml_event_t& event);
void HandleObjectsEvent(yaml_event_t& event); void HandleObjectsEvent(yaml_event_t& event);