SceneItem* Scene::InsertImageSource(UINT pos, XElement *sourceElement) { if(GetSceneItem(sourceElement->GetName()) != NULL) { AppWarning(TEXT("Scene source '%s' already in scene. actually, no one should get this error. if you do send it to jim immidiately."), sourceElement->GetName()); return NULL; } if(pos > sceneItems.Num()) { AppWarning(TEXT("Scene::InsertImageSource: pos >= sceneItems.Num()")); pos = sceneItems.Num(); } CTSTR lpClass = sourceElement->GetString(TEXT("class")); ImageSource *source = NULL; if(!lpClass) AppWarning(TEXT("No class for source '%s' in scene '%s'"), sourceElement->GetName(), API->GetSceneElement()->GetName()); else { source = API->CreateImageSource(lpClass, sourceElement->GetElement(TEXT("data"))); if(!source) AppWarning(TEXT("Could not create image source '%s' in scene '%s'"), sourceElement->GetName(), API->GetSceneElement()->GetName()); } float x = sourceElement->GetFloat(TEXT("x")); float y = sourceElement->GetFloat(TEXT("y")); float cx = sourceElement->GetFloat(TEXT("cx"), 100); float cy = sourceElement->GetFloat(TEXT("cy"), 100); bool render = sourceElement->GetInt(TEXT("render"), 1) > 0; SceneItem *item = new SceneItem; item->element = sourceElement; item->parent = this; item->source = source; item->pos = Vect2(x, y); item->size = Vect2(cx, cy); item->crop.w = sourceElement->GetFloat(TEXT("crop.top")); item->crop.x = sourceElement->GetFloat(TEXT("crop.left")); item->crop.y = sourceElement->GetFloat(TEXT("crop.bottom")); item->crop.z = sourceElement->GetFloat(TEXT("crop.right")); item->SetRender(render); API->EnterSceneMutex(); if(bSceneStarted) source->BeginScene(); sceneItems.Insert(pos, item); API->LeaveSceneMutex(); if(!source) bMissingSources = true; return item; }
SceneItem* Scene::InsertImageSource(UINT pos, XElement *sourceElement) { if(GetSceneItem(sourceElement->GetName()) != NULL) { AppWarning(TEXT("Scene source '%s' already in scene. actually, no one should get this error. if you do send it to jim immidiately."), sourceElement->GetName()); return NULL; } if(pos > sceneItems.Num()) { AppWarning(TEXT("Scene::InsertImageSource: pos >= sceneItems.Num()")); pos = sceneItems.Num(); } bool render = sourceElement->GetInt(TEXT("render"), 1) > 0; float x = sourceElement->GetFloat(TEXT("x")); float y = sourceElement->GetFloat(TEXT("y")); float cx = sourceElement->GetFloat(TEXT("cx"), 100); float cy = sourceElement->GetFloat(TEXT("cy"), 100); SceneItem *item = new SceneItem; item->element = sourceElement; item->parent = this; item->pos = Vect2(x, y); item->size = Vect2(cx, cy); item->crop.w = sourceElement->GetFloat(TEXT("crop.right")); item->crop.x = sourceElement->GetFloat(TEXT("crop.left")); item->crop.y = sourceElement->GetFloat(TEXT("crop.top")); item->crop.z = sourceElement->GetFloat(TEXT("crop.bottom")); item->SetRender(render); API->EnterSceneMutex(); sceneItems.Insert(pos, item); API->LeaveSceneMutex(); /*if(!source) bMissingSources = true;*/ return item; }