예제 #1
0
Error MyApp::init()
{
	// Init the super class
	Config config;
	config.set("fullscreenDesktopResolution", true);
	config.set("dataPaths", ".:..");
	config.set("debugContext", 0);
	ANKI_CHECK(App::init(config, allocAligned, nullptr));

	// Load the scene.lua
	ScriptResourcePtr script;
	ANKI_CHECK(getResourceManager().loadResource("samples/assets/scene.lua", script));
	ANKI_CHECK(getScriptManager().evalString(script->getSource()));

	// Input
	getInput().lockCursor(true);
	getInput().hideCursor(true);
	getInput().moveCursor(Vec2(0.0));

	// Some renderer stuff
	getMainRenderer().getOffscreenRenderer().getVolumetric().setFog(Vec3(1.0, 0.9, 0.9), 0.7);

	return ErrorCode::NONE;
}
예제 #2
0
Error MyApp::init(int argc, char* argv[])
{
	if(argc < 3)
	{
		ANKI_LOGE("usage: %s /path/to/config.xml relative/path/to/scene.lua", argv[0]);
		return Error::USER_DATA;
	}

	// Config
	Config config;
	ANKI_CHECK(config.loadFromFile(argv[1]));
	ANKI_CHECK(config.setFromCommandLineArguments(argc, argv));
	// ANKI_CHECK(config.saveToFile(argv[1]));

	// Init super class
	ANKI_CHECK(App::init(config, allocAligned, nullptr));

	// Other init
	MainRenderer& renderer = getMainRenderer();
	ResourceManager& resources = getResourceManager();

	renderer.getOffscreenRenderer().getVolumetricFog().setFogParticleColor(Vec3(1.0, 0.9, 0.9));
	renderer.getOffscreenRenderer().getVolumetricFog().setParticleDensity(1.0f);

	if(getenv("PROFILE"))
	{
		m_profile = true;
		setTimerTick(0.0);
		CoreTracerSingleton::get().m_enabled = true;
	}

// Input
#if MOUSE
	getInput().lockCursor(true);
	getInput().hideCursor(true);
	getInput().moveCursor(Vec2(0.0));
#endif

	// Load scene
	ScriptResourcePtr script;
	ANKI_CHECK(resources.loadResource(argv[2], script));
	ANKI_CHECK(getScriptManager().evalString(script->getSource()));

	// ANKI_CHECK(renderer.getOffscreenRenderer().getFinalComposite().loadColorGradingTexture(
	//	"textures/color_gradient_luts/forge_lut.ankitex"));

#if PLAYER
	SceneGraph& scene = getSceneGraph();
	SceneNode& cam = scene.getActiveCameraNode();

	PlayerNode* pnode;
	ANKI_CHECK(scene.newSceneNode<PlayerNode>(
		"player", pnode, cam.getComponent<MoveComponent>().getLocalOrigin() - Vec4(0.0, 1.0, 0.0, 0.0)));

	cam.getComponent<MoveComponent>().setLocalTransform(
		Transform(Vec4(0.0, 0.0, 0.0, 0.0), Mat3x4::getIdentity(), 1.0));

	pnode->addChild(&cam);
#endif

	return Error::NONE;
}