コード例 #1
0
void SetSwitchIndexHelper::ProcessSwitchIndexUpdate(uint32 value, eSET_SWITCH_INDEX state)
{
	for(int i = 0; i < SceneDataManager::Instance()->SceneCount(); ++i)
	{
		SceneData *sceneData = SceneDataManager::Instance()->SceneGet(i);
		
		List<SceneNode*> switchComponents;
		if( SetSwitchIndexHelper::FOR_SELECTED == state)
		{
			SceneNode *selectedNode = SceneDataManager::Instance()->SceneGetSelectedNode(sceneData);
			if(NULL != selectedNode)
			{
				selectedNode->FindAllSwitchComponentsRecursive(switchComponents);
			}
		}
		if( SetSwitchIndexHelper::FOR_SCENE == state)
		{
			sceneData->GetScene()->FindAllSwitchComponentsRecursive( switchComponents);
		}
		
		for(List<SceneNode*>::const_iterator it = switchComponents.begin(); it != switchComponents.end(); ++it)
		{
			
			SwitchComponent * switchComponent = cast_if_equal<SwitchComponent*>((*it)->GetComponent(Component::SWITCH_COMPONENT));
			if(NULL != switchComponent)
			{
				uint32 rangeSize = switchComponent->GetEntity()->GetChildrenCount();
				switchComponent->SetSwitchIndex(value);
			}
		}
	}
}
コード例 #2
0
void SceneEditorScreenMain::NewScene()
{
	SceneData *levelScene = SceneDataManager::Instance()->CreateNewScene();
    
    bodies[0]->bodyControl->SetScene(levelScene->GetScene());
    bodies[0]->bodyControl->Refresh();
}
コード例 #3
0
void QSceneGraphTreeView::ShowSceneGraphMenu(const QModelIndex &index, const QPoint &point)
{
    if(!index.isValid())
    {
        return;
    }
    
    QMenu menu;
    
	// For "custom" Particles Editor nodes the "generic" ones aren't needed".
    if (sceneGraphModel->GetParticlesEditorSceneModelHelper().NeedDisplaySceneEditorPopupMenuItems(index))
    {
		SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
		LandscapesController *landsacpesController = activeScene->GetLandscapesController();

		SceneEditorScreenMain *screen = static_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen(SCREEN_MAIN_OLD));
		EditorBodyControl *c = screen->FindCurrentBody()->bodyControl;

		bool canChangeScene = !landsacpesController->EditorLandscapeIsActive() && !c->LandscapeEditorActive();
		if(!canChangeScene)
			return;



		AddActionToMenu(&menu, QString("Look at Object"), new CommandLockAtObject());
		AddActionToMenu(&menu, QString("Remove Object"), new CommandRemoveSceneNode());
	
		AddActionToMenu(&menu, QString("Debug Flags"), new CommandDebugFlags());
    
		Entity *node = static_cast<Entity *>(sceneGraphModel->ItemData(index));
		if (node)
		{
            SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
            if(node->GetParent() == activeScene->GetScene())
            {
                KeyedArchive *properties = node->GetCustomProperties();
                if (properties && properties->IsKeyExists(String(ResourceEditor::EDITOR_REFERENCE_TO_OWNER)))
                {
                    String filePathname = properties->GetString(String(ResourceEditor::EDITOR_REFERENCE_TO_OWNER));

                    AddActionToMenu(&menu, QString("Remove Root Nodes"), new CommandRemoveRootNodes());
				}
			}
			FilePath filePathForSaveAs(activeScene->GetScenePathname());
			AddActionToMenu(&menu, QString("Save Scene As"), new CommandSaveSpecifiedScene(node, filePathForSaveAs));
		}
	}
	
	// For "custom" Particles Editor nodes the "generic" ones aren't needed".
    // We might need more menu items/actions for Particles Editor.
    sceneGraphModel->GetParticlesEditorSceneModelHelper().AddPopupMenuItems(menu, index);

    connect(&menu, SIGNAL(triggered(QAction *)), this, SLOT(SceneGraphMenuTriggered(QAction *)));
    menu.exec(point);
}
コード例 #4
0
void SceneEditorScreenMain::AddBodyItem(const WideString &text, bool isCloseable)
{
    HideScenePreview();
    
    EditorScene *scene = SceneDataManager::Instance()->RegisterNewScene();
    SceneDataManager::Instance()->SetActiveScene(scene);
    
    BodyItem *c = new BodyItem();
    
    int32 count = bodies.size();
    
    c->headerButton = ControlsFactory::CreateButton(
                                                    Vector2(0 + count * (ControlsFactory::BUTTON_WIDTH + 1), 0),
                                                    text);
    Rect fullRect = GetRect();
    c->bodyControl = new EditorBodyControl(Rect(0, ControlsFactory::BUTTON_HEIGHT + 1, fullRect.dx, fullRect.dy - ControlsFactory::BUTTON_HEIGHT - 1));
    
    
    c->headerButton->SetTag(count);
    c->headerButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnSelectBody));
    if(isCloseable)
    {
        c->closeButton = ControlsFactory::CreateCloseWindowButton(
                                                                  Rect(ControlsFactory::BUTTON_WIDTH - ControlsFactory::BUTTON_HEIGHT, 0,
                                                                       ControlsFactory::BUTTON_HEIGHT, ControlsFactory::BUTTON_HEIGHT));
        c->closeButton->SetTag(count);
        c->closeButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &SceneEditorScreenMain::OnCloseBody));
        c->headerButton->AddControl(c->closeButton);
    }
    else 
    {
        c->closeButton = NULL;
    }

    
    SceneData *sceneData = SceneDataManager::Instance()->SceneGetActive();
    c->bodyControl->SetScene(sceneData->GetScene());
    c->bodyControl->SetCameraController(sceneData->GetCameraController());
    c->bodyControl->SetTag(count);
    
    AddControl(c->headerButton);    
    bodies.push_back(c);
    
    //set as current
    c->headerButton->PerformEvent(UIControl::EVENT_TOUCH_UP_INSIDE);
}
コード例 #5
0
void LodDistanceControl::UpdateDistanceToCamera()
{
    SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
    DVASSERT(activeScene);

    EditorScene *scene = activeScene->GetScene();
    DVASSERT(scene);

    Entity *selection = scene->GetSelection();
    if(selection)
    {
        Camera *activeCamera = scene->GetCurrentCamera();
        
        Vector3 cameraPosition = activeCamera->GetPosition();
        Vector3 selectionCenter = selection->GetWTMaximumBoundingBoxSlow().GetCenter();
        
        float32 distanceToCamera = (cameraPosition-selectionCenter).Length();
        distanceToCameraValue->SetText(Format(L"%f", distanceToCamera));
    }
}
コード例 #6
0
void CreateNodesDialog::CreateNode(ResourceEditor::eNodeType nodeType)
{
    SafeRelease(sceneNode);

    SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
    EditorScene * editorScene = activeScene->GetScene();
	scene = editorScene;

    switch (nodeType) 
    {
        case ResourceEditor::NODE_LANDSCAPE:
            SetHeader(LocalizedString(L"createnode.landscape"));
            sceneNode = new Entity();
            sceneNode->AddComponent(new RenderComponent(ScopedPtr<Landscape>(new Landscape())));
            sceneNode->SetName("Landscape");
            break;

        case ResourceEditor::NODE_LIGHT:
        {
            SetHeader(LocalizedString(L"createnode.light"));
            
            //sceneNode = //EditorLightNode::CreateSceneAndEditorLight();
            sceneNode = new Entity();
            sceneNode->AddComponent(new LightComponent(ScopedPtr<Light>(new Light)));
            sceneNode->SetName("Light");
            break;
        }

        case ResourceEditor::NODE_SERVICE_NODE:
        {
            SetHeader(LocalizedString(L"createnode.servicenode"));
            sceneNode = new Entity();
            KeyedArchive *customProperties = sceneNode->GetCustomProperties();
            customProperties->SetBool("editor.isLocked", true);
            sceneNode->SetName("Servicenode");
            break;
        }

        case ResourceEditor::NODE_CAMERA:
        {
            SetHeader(LocalizedString(L"createnode.camera"));
            sceneNode = new Entity();
            
            Camera * camera = new Camera();
            camera->SetUp(Vector3(0.0f, 0.0f, 1.0f));
            sceneNode->AddComponent(new CameraComponent(camera));
            sceneNode->SetName("Camera");
            SafeRelease(camera);
        }break;

		case ResourceEditor::NODE_IMPOSTER:
			SetHeader(LocalizedString(L"createnode.imposter"));
			sceneNode = new ImposterNode();
			sceneNode->SetName("Imposter");
			break;

		case ResourceEditor::NODE_PARTICLE_EMITTER:
		{
			SetHeader(LocalizedString(L"createnode.particleemitter"));
			sceneNode = new Entity();
			sceneNode->SetName("Particle Emitter");

			ParticleEmitter3D* newEmitter = new ParticleEmitter3D();

			RenderComponent * renderComponent = new RenderComponent();
			renderComponent->SetRenderObject(newEmitter);
			sceneNode->AddComponent(renderComponent);
            
            newEmitter->Release();

			break;
		}

		case ResourceEditor::NODE_USER_NODE:
        {
			SetHeader(LocalizedString(L"createnode.usernode"));
			sceneNode = new Entity();
			sceneNode->SetName("UserNode");
			sceneNode->AddComponent(new UserComponent());
			break;
        }

		case ResourceEditor::NODE_SWITCH_NODE:
		{
			SetHeader(LocalizedString(L"createnode.switchnode"));
            sceneNode = new Entity();
			sceneNode->SetName("SwitchNode");
            sceneNode->AddComponent(new SwitchComponent());
            
			KeyedArchive *customProperties = sceneNode->GetCustomProperties();
			customProperties->SetBool(Entity::SCENE_NODE_IS_SOLID_PROPERTY_NAME, false);
		}
			break;


		case ResourceEditor::NODE_PARTICLE_EFFECT:
		{
			SetHeader(L"Particle Effect");

			sceneNode = new Entity();
			ParticleEffectComponent* newEffectComponent = new ParticleEffectComponent();
			sceneNode->AddComponent(newEffectComponent);
			sceneNode->SetName("Particle Effect");

			break;
		}

        default:
            break;
    }

	propertyList = PropertyControlCreator::Instance()->CreateControlForNode(sceneNode, propertyRect, true);
    SafeRetain(propertyList);
	AddControl(propertyList);

	SetScene(editorScene);
    
    propertyList->ReadFrom(sceneNode);
}
コード例 #7
0
void CreateNodesDialog::CreateNode(ResourceEditor::eNodeType nodeType)
{
    SafeRelease(sceneNode);

    SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
    EditorScene * editorScene = activeScene->GetScene();
	scene = editorScene;

    switch (nodeType) 
    {
        case ResourceEditor::NODE_LANDSCAPE:
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_LANDSCAPE));
            sceneNode = new Entity();
            sceneNode->AddComponent(ScopedPtr<RenderComponent> (new RenderComponent(ScopedPtr<Landscape>(new Landscape()))));
            sceneNode->SetName(ResourceEditor::LANDSCAPE_NODE_NAME);
            break;

        case ResourceEditor::NODE_LIGHT:
        {
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_LIGHT));
            
            //sceneNode = //EditorLightNode::CreateSceneAndEditorLight();
            sceneNode = new Entity();
            sceneNode->AddComponent(ScopedPtr<LightComponent> (new LightComponent(ScopedPtr<Light>(new Light))));
            sceneNode->SetName(ResourceEditor::LIGHT_NODE_NAME);
            break;
        }

        case ResourceEditor::NODE_SERVICE_NODE:
        {
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_SERVICE));
            sceneNode = new Entity();
            KeyedArchive *customProperties = sceneNode->GetCustomProperties();
            customProperties->SetBool(ResourceEditor::EDITOR_IS_LOCKED, true);
            sceneNode->SetName(ResourceEditor::SERVICE_NODE_NAME);
            break;
        }

        case ResourceEditor::NODE_CAMERA:
        {
            SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_CAMERA));
            sceneNode = new Entity();
            
            Camera * camera = new Camera();
            camera->SetUp(Vector3(0.0f, 0.0f, 1.0f));
            sceneNode->AddComponent(ScopedPtr<CameraComponent> (new CameraComponent(camera)));
            sceneNode->SetName(ResourceEditor::CAMERA_NODE_NAME);
            SafeRelease(camera);
        }break;

		case ResourceEditor::NODE_IMPOSTER:
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_IMPOSTER));
			sceneNode = new ImposterNode();
			sceneNode->SetName(ResourceEditor::IMPOSTER_NODE_NAME);
			break;

		case ResourceEditor::NODE_PARTICLE_EMITTER:
		{
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_PARTICLE_EMITTER));
			sceneNode = new Entity();
			sceneNode->SetName(ResourceEditor::PARTICLE_EMITTER_NODE_NAME);

			ParticleEmitter3D* newEmitter = new ParticleEmitter3D();

			RenderComponent * renderComponent = new RenderComponent();
			renderComponent->SetRenderObject(newEmitter);
			sceneNode->AddComponent(renderComponent);
            
            newEmitter->Release();
			renderComponent->Release();

			break;
		}

		case ResourceEditor::NODE_USER_NODE:
        {
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_USER));
			sceneNode = new Entity();
			sceneNode->SetName(ResourceEditor::USER_NODE_NAME);
			sceneNode->AddComponent(ScopedPtr<UserComponent> (new UserComponent()));
			break;
        }

		case ResourceEditor::NODE_SWITCH_NODE:
		{
			SetHeader(LocalizedString(ResourceEditor::CREATE_NODE_SWITCH));
            sceneNode = new Entity();
			sceneNode->SetName(ResourceEditor::SWITCH_NODE_NAME);
            sceneNode->AddComponent(ScopedPtr<SwitchComponent> (new SwitchComponent()));
            
			KeyedArchive *customProperties = sceneNode->GetCustomProperties();
			customProperties->SetBool(Entity::SCENE_NODE_IS_SOLID_PROPERTY_NAME, false);
		}
			break;


		case ResourceEditor::NODE_PARTICLE_EFFECT:
		{
			SetHeader(ResourceEditor::CREATE_NODE_PARTICLE_EFFECT);

			sceneNode = new Entity();
			sceneNode->AddComponent(ScopedPtr<ParticleEffectComponent> (new ParticleEffectComponent()));
			sceneNode->SetName(ResourceEditor::PARTICLE_EFFECT_NODE_NAME);

			break;
		}

		case ResourceEditor::NODE_SKYBOX:
		{
			SetHeader(L"SkyBox");
			
			//TODO: add skybox creation code here
			break;
		}

        default:
            break;
    }

	propertyList = PropertyControlCreator::Instance()->CreateControlForNode(sceneNode, propertyRect, true);
    SafeRetain(propertyList);
	AddControl(propertyList);

	SetScene(editorScene);
    
    propertyList->ReadFrom(sceneNode);
}