Пример #1
0
void GameView::init(Lumix::WorldEditor& editor)
{
	m_editor = &editor;
	auto& engine = editor.getEngine();
	auto* renderer = static_cast<Lumix::Renderer*>(engine.getPluginManager().getPlugin("renderer"));
	Lumix::Path path("pipelines/game_view.lua");
	m_pipeline = Lumix::Pipeline::create(*renderer, path, engine.getAllocator());
	m_pipeline->load();

	editor.universeCreated().bind<GameView, &GameView::onUniverseCreated>(this);
	editor.universeDestroyed().bind<GameView, &GameView::onUniverseDestroyed>(this);
	onUniverseCreated();
}
Пример #2
0
bool SceneView::init(LogUI& log_ui, Lumix::WorldEditor& editor, Lumix::Array<Action*>& actions)
{
	m_log_ui = &log_ui;
	m_editor = &editor;
	auto& engine = editor.getEngine();
	auto& allocator = engine.getAllocator();
	auto* renderer = static_cast<Lumix::Renderer*>(engine.getPluginManager().getPlugin("renderer"));
	m_is_opengl = renderer->isOpenGL();
	Lumix::Path path("pipelines/main.lua");
	m_pipeline = Lumix::Pipeline::create(*renderer, path, engine.getAllocator());
	m_pipeline->load();
	m_pipeline->addCustomCommandHandler("renderGizmos")
		.callback.bind<SceneView, &SceneView::renderGizmos>(this);
	m_pipeline->addCustomCommandHandler("renderIcons")
		.callback.bind<SceneView, &SceneView::renderIcons>(this);

	editor.universeCreated().bind<SceneView, &SceneView::onUniverseCreated>(this);
	editor.universeDestroyed().bind<SceneView, &SceneView::onUniverseDestroyed>(this);

	m_toggle_gizmo_step_action =
		LUMIX_NEW(editor.getAllocator(), Action)("Enable/disable gizmo step", "toggleGizmoStep");
	m_toggle_gizmo_step_action->is_global = false;
	actions.push(m_toggle_gizmo_step_action);

	m_move_forward_action = LUMIX_NEW(editor.getAllocator(), Action)("Move forward", "moveForward");
	m_move_forward_action->is_global = false;
	actions.push(m_move_forward_action);

	m_move_back_action = LUMIX_NEW(editor.getAllocator(), Action)("Move back", "moveBack");
	m_move_back_action->is_global = false;
	actions.push(m_move_back_action);

	m_move_left_action = LUMIX_NEW(editor.getAllocator(), Action)("Move left", "moveLeft");
	m_move_left_action->is_global = false;
	actions.push(m_move_left_action);

	m_move_right_action = LUMIX_NEW(editor.getAllocator(), Action)("Move right", "moveRight");
	m_move_right_action->is_global = false;
	actions.push(m_move_right_action);

	m_move_up_action = LUMIX_NEW(editor.getAllocator(), Action)("Move up", "moveUp");
	m_move_up_action->is_global = false;
	actions.push(m_move_up_action);

	m_move_down_action = LUMIX_NEW(editor.getAllocator(), Action)("Move down", "moveDown");
	m_move_down_action->is_global = false;
	actions.push(m_move_down_action);

	return true;
}
Пример #3
0
ShaderCompiler::ShaderCompiler(Lumix::WorldEditor& editor, LogUI& log_ui)
	: m_editor(editor)
	, m_log_ui(log_ui)
	, m_dependencies(editor.getAllocator())
	, m_to_reload(editor.getAllocator())
	, m_processes(editor.getAllocator())
	, m_changed_files(editor.getAllocator())
	, m_mutex(false)
{
	m_notifications_id = -1;
	m_is_compiling = false;
	
	m_watcher = FileSystemWatcher::create("shaders", m_editor.getAllocator());
	m_watcher->getCallback()
		.bind<ShaderCompiler, &ShaderCompiler::onFileChanged>(this);
	parseDependencies();
	makeUpToDate();
}
Пример #4
0
PropertyGrid::PropertyGrid(Lumix::WorldEditor& editor,
	AssetBrowser& asset_browser,
	Lumix::Array<Action*>& actions)
	: m_is_opened(true)
	, m_editor(editor)
	, m_asset_browser(asset_browser)
	, m_plugins(editor.getAllocator())
{
	m_particle_emitter_updating = true;
	m_particle_emitter_timescale = 1.0f;
	m_filter[0] = '\0';
}
Пример #5
0
void getEntityListDisplayName(Lumix::WorldEditor& editor,
	char* buf,
	int max_size,
	Lumix::Entity entity)
{
	const char* name = editor.getUniverse()->getEntityName(entity);
	static const Lumix::uint32 RENDERABLE_HASH = Lumix::crc32("renderable");
	Lumix::ComponentUID renderable = editor.getComponent(entity, RENDERABLE_HASH);
	if (renderable.isValid())
	{
		auto* scene = static_cast<Lumix::RenderScene*>(renderable.scene);
		const char* path = scene->getRenderablePath(renderable.index);
		if (path && path[0] != 0)
		{
			char basename[Lumix::MAX_PATH_LENGTH];
			Lumix::copyString(buf, max_size, path);
			Lumix::PathUtils::getBasename(basename, Lumix::MAX_PATH_LENGTH, path);
			if (name && name[0] != '\0')
				Lumix::copyString(buf, max_size, name);
			else
				Lumix::toCString(entity, buf, max_size);

			Lumix::catString(buf, max_size, " - ");
			Lumix::catString(buf, max_size, basename);
			return;
		}
	}

	if (name && name[0] != '\0')
	{
		Lumix::copyString(buf, max_size, name);
	}
	else
	{
		Lumix::toCString(entity, buf, max_size);
	}
}
Пример #6
0
AssetBrowser::AssetBrowser(Lumix::WorldEditor& editor, Metadata& metadata)
	: m_editor(editor)
	, m_metadata(metadata)
	, m_resources(editor.getAllocator())
	, m_selected_resource(nullptr)
	, m_autoreload_changed_resource(true)
	, m_changed_files(editor.getAllocator())
	, m_is_focus_requested(false)
	, m_changed_files_mutex(false)
	, m_history(editor.getAllocator())
	, m_plugins(editor.getAllocator())
	, m_on_resource_changed(editor.getAllocator())
{
	m_is_update_enabled = true;
	m_filter[0] = '\0';
	m_current_type = 0;
	m_is_opened = false;
	m_activate = false;
	m_resources.emplace(editor.getAllocator());

	findResources();

	const char* base_path = editor.getEngine().getDiskFileDevice()->getBasePath();
	m_watchers[0] = FileSystemWatcher::create(base_path, editor.getAllocator());
	m_watchers[0]->getCallback().bind<AssetBrowser, &AssetBrowser::onFileChanged>(this);
	if (editor.getEngine().getPatchFileDevice())
	{
		base_path = editor.getEngine().getPatchFileDevice()->getBasePath();
		m_watchers[1] = FileSystemWatcher::create(base_path, editor.getAllocator());
		m_watchers[1]->getCallback().bind<AssetBrowser, &AssetBrowser::onFileChanged>(this);
	}
	else
	{
		m_watchers[1] = nullptr;
	}
}