scanning scene files for camera definitions before shapes and lights
git-svn-id: svn://anubis/fart/trunk@194 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
12eb2f2476
commit
db72b5ba82
1
.todo
1
.todo
@ -1,5 +1,4 @@
|
|||||||
FART To-Do List
|
FART To-Do List
|
||||||
===============
|
===============
|
||||||
- Scan for cameras before scene items
|
|
||||||
- Test subtractions of subtractions
|
- Test subtractions of subtractions
|
||||||
- Add built-in timing around Scene::render()
|
- Add built-in timing around Scene::render()
|
||||||
|
@ -23,7 +23,7 @@ void Scene::processNode(refptr<Node> node)
|
|||||||
|
|
||||||
if ( typeid(*node) == typeid(SceneNode) )
|
if ( typeid(*node) == typeid(SceneNode) )
|
||||||
{
|
{
|
||||||
processChildren(node);
|
processScene(node);
|
||||||
}
|
}
|
||||||
else if ( node->isShape() )
|
else if ( node->isShape() )
|
||||||
{
|
{
|
||||||
@ -37,10 +37,6 @@ void Scene::processNode(refptr<Node> node)
|
|||||||
if ( ! light.isNull() )
|
if ( ! light.isNull() )
|
||||||
m_lights.push_back(light);
|
m_lights.push_back(light);
|
||||||
}
|
}
|
||||||
else if ( typeid(*node) == typeid(CameraNode) )
|
|
||||||
{
|
|
||||||
processCamera(node);
|
|
||||||
}
|
|
||||||
else if ( typeid(*node) == typeid(OptionsNode) )
|
else if ( typeid(*node) == typeid(OptionsNode) )
|
||||||
{
|
{
|
||||||
processOptions(node);
|
processOptions(node);
|
||||||
@ -68,6 +64,47 @@ void Scene::processNode(refptr<Node> node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::processChildren(refptr<Node> node)
|
||||||
|
{
|
||||||
|
std::vector< refptr<Node> > & children = node->getChildren();
|
||||||
|
for (int i = 0, sz = children.size(); i < sz; i++)
|
||||||
|
{
|
||||||
|
processNode(children[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::processScene(refptr<Node> node)
|
||||||
|
{
|
||||||
|
/* first process any cameras present */
|
||||||
|
int cameras_found = 0;
|
||||||
|
for (Node_Iterator it = node->getChildren().begin();
|
||||||
|
it != node->getChildren().end();
|
||||||
|
it++)
|
||||||
|
{
|
||||||
|
if ( typeid(**it) == typeid(CameraNode) )
|
||||||
|
{
|
||||||
|
cameras_found++;
|
||||||
|
if (cameras_found == 1)
|
||||||
|
processCamera(*it);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cerr << "Error: multiple camera definitions found!" << endl;
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Node_Iterator it = node->getChildren().begin();
|
||||||
|
it != node->getChildren().end();
|
||||||
|
it++)
|
||||||
|
{
|
||||||
|
if ( typeid(**it) != typeid(CameraNode) )
|
||||||
|
{
|
||||||
|
processNode(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
refptr<Shape> Scene::processShape(refptr<Node> node)
|
refptr<Shape> Scene::processShape(refptr<Node> node)
|
||||||
{
|
{
|
||||||
if ( typeid(*node) == typeid(BoxNode) )
|
if ( typeid(*node) == typeid(BoxNode) )
|
||||||
@ -102,15 +139,6 @@ refptr<Shape> Scene::processShape(refptr<Node> node)
|
|||||||
return refptr<Shape>(NULL);
|
return refptr<Shape>(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::processChildren(refptr<Node> node)
|
|
||||||
{
|
|
||||||
std::vector< refptr<Node> > & children = node->getChildren();
|
|
||||||
for (int i = 0, sz = children.size(); i < sz; i++)
|
|
||||||
{
|
|
||||||
processNode(children[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::processCamera(refptr<Node> node)
|
void Scene::processCamera(refptr<Node> node)
|
||||||
{
|
{
|
||||||
Vector position(0, 0, 0);
|
Vector position(0, 0, 0);
|
||||||
|
@ -63,6 +63,7 @@ class Scene
|
|||||||
void load(const char * filename);
|
void load(const char * filename);
|
||||||
void processNode(refptr<Node> node);
|
void processNode(refptr<Node> node);
|
||||||
void processChildren(refptr<Node> node);
|
void processChildren(refptr<Node> node);
|
||||||
|
void processScene(refptr<Node> node);
|
||||||
refptr<Material> processMaterial(refptr<Node> node);
|
refptr<Material> processMaterial(refptr<Node> node);
|
||||||
refptr<Shape> processBox(refptr<Node> node);
|
refptr<Shape> processBox(refptr<Node> node);
|
||||||
refptr<Shape> processCyl(refptr<Node> node);
|
refptr<Shape> processCyl(refptr<Node> node);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user