示例#1
0
文件: scene.cpp 项目: ronj/invent
void Scene::__addObject( const Object3D::Ptr& object ) {
  if ( !object )
    return;

  detail::Add objectAdd( *this, object );
  object->visit( objectAdd );


  dispatchEvent( Event("objectAdded", object.get()) );
  object->dispatchEvent( Event("addedToScene", this) );

  for ( auto& child : object->children ) {
    __addObject( child );
  }
}
示例#2
0
文件: Scene.cpp 项目: wibbe/three-cpp
  void Scene::__addObject(Object * object)
  {
    if (dynamic_cast<Light *>(object))
    {
      lights.push_back(object);
    }
    else if (!dynamic_cast<Camera *>(object))
    {
      objects.push_back(object);
      objectsAdded.push_back(object);

      objectsRemoved.erase(std::remove(objectsRemoved.begin(), objectsRemoved.end(), object), objectsRemoved.end());
    }

    for (std::vector<Object *>::iterator it = object->children.begin(), end = object->children.end(); it != end; ++it)
      __addObject(*it);
  }