Example #1
0
void GameScript::setWaterHeight(float value)
{
	if (gEnv->terrainManager && gEnv->terrainManager->getWater())
	{
		IWater* water = gEnv->terrainManager->getWater();
		water->setCamera(gEnv->mainCamera);
		water->setHeight(value);
		water->update();
	}
}
void SurveyMapTextureCreator::postRenderTargetUpdate()
{
	Beam **trucks = BeamFactory::getSingleton().getTrucks();

	for (int i=0; i < BeamFactory::getSingleton().getTruckCount(); i++)
		if (trucks[i])
			trucks[i]->preMapLabelRenderUpdate(false);

	if (mStatics)
		mStatics->setRenderingDistance(1000);

	IWater* water = gEnv->terrainManager->getWater();
	if (water)
	{
		water->setCamera(gEnv->mainCamera);
		water->moveTo(water->getHeight());
		water->update();
	}
}
Example #3
0
int
main( int argc, char *argv[] )
{
     DFBResult              ret;
     DFBSurfaceDescription  desc;
     IDirectFB             *dfb;
     IDirectFBSurface      *surface;
     IWater                *water;

     D_INFO( "Tests/Water: Starting up...\n" );

     /* Initialize DirectFB including command line parsing. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          DirectFBError( "DirectFBInit() failed", ret );
          return -1;
     }

     /* Parse the command line. */
     if (!parse_command_line( argc, argv ))
          return -2;

     /* Create the super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          DirectFBError( "DirectFBCreate() failed", ret );
          return -3;
     }

     /* Fill surface description, flipping primary. */
     desc.flags = DSDESC_CAPS;
     desc.caps  = DSCAPS_PRIMARY | DSCAPS_FLIPPING;

     /* Set width or height? */
     if (m_width > 0) {
          desc.flags |= DSDESC_WIDTH;
          desc.width  = m_width;
     }
     if (m_height > 0) {
          desc.flags |= DSDESC_HEIGHT;
          desc.height = m_height;
     }

     /* Set pixel format? */
     if (m_format != DSPF_UNKNOWN) {
          desc.flags       |= DSDESC_PIXELFORMAT;
          desc.pixelformat  = m_format;
     }

     dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );

     /* Create a primary surface. */
     ret = dfb->CreateSurface( dfb, &desc, &surface );
     if (ret) {
          D_DERROR( ret, "IDirectFB::CreateSurface() failed!\n" );
          dfb->Release( dfb );
          return -4;
     }

     /* Get the extended rendering interface. */
     ret = dfb->GetInterface( dfb, "IWater", NULL, dfb, (void**) &water );
     if (ret) {
          DirectFBError( "IDirectFB::GetInterface( 'IWater' ) failed", ret );
          surface->Release( surface );
          dfb->Release( dfb );
          return -5;
     }


     D_INFO( "Tests/Water: Got render interface, running tests...\n" );

     RunTest( Test_Simple, water, surface );

     RunTest( Test_RenderElement, water, surface );

     RunTest( Test_RenderElements, water, surface );

     RunTest( Test_RenderShape, water, surface );

     RunTest( Test_RenderShapes, water, surface );


     D_INFO( "Tests/Water: Dumping surface...\n" );

     unlink( "dfbrender.pgm" );
     unlink( "dfbrender.ppm" );
     surface->Dump( surface, "dfbrender", NULL );


     D_INFO( "Tests/Water: Shutting down...\n" );

     /* Release the render interface. */
     water->Release( water );

     /* Release the surface. */
     surface->Release( surface );

     /* Release the super interface. */
     dfb->Release( dfb );

     return EXIT_SUCCESS;
}
Example #4
0
/*
All commands are here
*/
void Console::eventCommandAccept(MyGUI::Edit* _sender)
{
	UTFString msg = convertFromMyGUIString(m_Console_TextBox->getCaption());

	// we did not autoComplete, so try to handle the message
	m_Console_TextBox->setCaption("");

	if (msg.empty())
	{
		// discard the empty message
		return;
	}
	if (msg[0] == '/' || msg[0] == '\\')
	{
		Ogre::StringVector args = StringUtil::split(msg, " ");
		sTextHistory[iText] = msg;
		iText++; //Used for text history
		if (args[0] == "/help")
		{
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_TITLE, _L("Available commands:"), "help.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/help - information on commands (this)"), "help.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/ver - shows the Rigs of Rods version"), "information.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/pos - outputs the current position"), "world.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/goto <x> <y> <z> - jumps to the mentioned position"), "world.png");


			//if (gEnv->terrainManager->getHeightFinder()) //Not needed imo -max98
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/terrainheight - get height of terrain at current position"), "world.png");

			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/log - toggles log output on the console"), "table_save.png");

			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/quit - exit Rigs of Rods"), "table_save.png");

#ifdef USE_ANGELSCRIPT	
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/as <code here> - interpret angel code using console"), "script_go.png");
#endif // USE_ANGELSCRIPT

			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/gravity <real> or <text string> - changes gravity constant. Outputs current value if no argument is given"), "script_go.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("Possible values: \n earth \n moon \n jupiter \n A random number (use negative)"), "script_go.png");

			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/setwaterlevel <real> - changes water's level"), "script_go.png");

			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_TITLE, _L("Tips:"), "help.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("- use Arrow Up/Down Keys in the InputBox to reuse old messages"), "information.png");
			return;
		} else if (args[0] == "/gravity")
		{
			float gValue;

			if (args.size() > 1)
			{
				if (args[1] == "earth")
					gValue = -9.81;
				else if (args[1] == "moon")
					gValue = -1.6;
				else if (args[1] == "jupiter")
					gValue = -50;
				else
					gValue = boost::lexical_cast<float>(args[1].c_str());
			} else
			{
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Current gravity is: ") + StringConverter::toString(gEnv->terrainManager->getGravity()), "information.png");
				return;
			}

			gEnv->terrainManager->setGravity(gValue);
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Gravity set to: ") + StringConverter::toString(gValue), "information.png");
			return;
		} else if (args[0] == "/setwaterlevel")
		{
			if (gEnv->terrainManager && gEnv->terrainManager->getWater() && args.size() > 1)
			{
				IWater* water = gEnv->terrainManager->getWater();
				water->setCamera(gEnv->mainCamera);
				water->setHeight(boost::lexical_cast<float>(args[1].c_str()));
				water->update();
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Water level set to: ") + StringConverter::toString(water->getHeight()), "information.png");
			}
			else
			{
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_ERROR, _L("Please enter a correct value. "), "information.png");
			}
			return;
		}
		else if (args[0] == "/pos" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED))
		{
			Beam *b = BeamFactory::getSingleton().getCurrentTruck();
			if (!b && gEnv->player)
			{
				Vector3 pos = gEnv->player->getPosition();
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Character position: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png");
			}
			else if (b)
			{
				Vector3 pos = b->getPosition();
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Vehicle position: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png");
			}

			return;
		}
		else if (args[0] == "/goto" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED))
		{
			if (args.size() != 4)
			{
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, ChatSystem::commandColour + _L("usage: /goto x y z"), "information.png");
				return;
			}

			Vector3 pos = Vector3(PARSEREAL(args[1]), PARSEREAL(args[2]), PARSEREAL(args[3]));

			Beam *b = BeamFactory::getSingleton().getCurrentTruck();
			if (!b && gEnv->player)
			{
				gEnv->player->setPosition(pos);
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Character position set to: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png");
			}
			else if (b)
			{
				b->resetPosition(pos, false);
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Vehicle position set to: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png");
			}

			return;
		}
		else if (args[0] == "/terrainheight" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED))
		{
			if (!gEnv->terrainManager->getHeightFinder()) return;
			Vector3 pos = Vector3::ZERO;

			Beam *b = BeamFactory::getSingleton().getCurrentTruck();
			if (!b && gEnv->player)
			{
				pos = gEnv->player->getPosition();
			}
			else if (b)
			{
				pos = b->getPosition();
			}

			Real h = gEnv->terrainManager->getHeightFinder()->getHeightAt(pos.x, pos.z);
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Terrain height at position: ") + String("x: ") + TOSTRING(pos.x) + String("z: ") + TOSTRING(pos.z) + _L(" = ")  + TOSTRING(h), "world.png");

			return;
		}
		else if (args[0] == "/ver")
		{
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_TITLE, "Rigs of Rods:", "information.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, " Version: " + String(ROR_VERSION_STRING), "information.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, " Protocol version: " + String(RORNET_VERSION), "information.png");
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, " build time: " + String(__DATE__) + ", " + String(__TIME__), "information.png");
			return;

		}
		else if (args[0] == "/quit")
		{
			Application::GetMainThreadLogic()->RequestExitCurrentLoop();
			Application::GetMainThreadLogic()->RequestShutdown();
			return;

		}
#ifdef USE_ANGELSCRIPT
		else if (args[0] == "/as" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED))
		{
			// we want to notify any running scripts that we might change something (prevent cheating)
			ScriptEngine::getSingleton().triggerEvent(SE_ANGELSCRIPT_MANIPULATIONS);

			String command = msg.substr(args[0].length());

			StringUtil::trim(command);
			if (command.empty()) return;

			String nmsg = ChatSystem::scriptCommandColour + ">>> " + ChatSystem::normalColour + command;
			putMessage(CONSOLE_MSGTYPE_SCRIPT, CONSOLE_LOCAL_SCRIPT, nmsg, "script_go.png");
			int res = ScriptEngine::getSingleton().executeString(command);
			return;
		}
#endif //ANGELSCRIPT
		else if (args[0] == "/log")
		{
			// switch to console logging
			bool logging = BSETTING("Enable Ingame Console", false);
			if (!logging)
			{
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_NOTICE, _L(" logging to console enabled"), "information.png");
				SETTINGS.setSetting("Enable Ingame Console", "Yes");
			}
			else
			{
				putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_NOTICE, _L(" logging to console disabled"), "information.png");
				SETTINGS.setSetting("Enable Ingame Console", "No");
			}
			return;
		}
		else
		{
			//TODO: Angelscript here
			putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_ERROR, _L("unknown command: ") + msg, "error.png");
		}
	}

}
Example #5
0
IWater* IWater::GetWater(IWater* currWaterRenderer, int nextWaterRendererMode)
{
	static IWater baseWaterRenderer;
	IWater* nextWaterRenderer = NULL;

	if (currWaterRenderer != NULL) {
		assert(water == currWaterRenderer);

		if (currWaterRenderer->GetID() == nextWaterRendererMode) {
			if (nextWaterRendererMode == IWater::WATER_RENDERER_BASIC) {
				return currWaterRenderer;
			}
		}

		// note: rendering thread(s) can concurrently dereference the
		// <water> global, so they may not see destructed memory while
		// it is being reinstantiated through <currWaterRenderer>
		water = &baseWaterRenderer;

		// for BumpWater, this needs to happen before a new renderer
		// instance is created because its shaders must be recompiled
		// (delayed deletion will fail)
		delete currWaterRenderer;
	}

	if (nextWaterRendererMode < IWater::WATER_RENDERER_BASIC) {
		nextWaterRendererMode = configHandler->GetInt("ReflectiveWater");
	}

	switch (nextWaterRendererMode) {
		case WATER_RENDERER_DYNAMIC: {
			const bool canLoad =
				GLEW_ARB_fragment_program &&
				GLEW_ARB_texture_float &&
				ProgramStringIsNative(GL_FRAGMENT_PROGRAM_ARB, "ARB/waterDyn.fp");

			if (canLoad) {
				try {
					nextWaterRenderer = new CDynWater();
				} catch (const content_error& ex) {
					delete nextWaterRenderer;
					nextWaterRenderer = NULL;
					LOG_L(L_ERROR, "Loading Dynamic Water failed, error: %s",
							ex.what());
				}
			}
		} break;

		case WATER_RENDERER_BUMPMAPPED: {
			const bool canLoad =
				GLEW_ARB_shading_language_100 &&
				GL_ARB_fragment_shader &&
				GL_ARB_vertex_shader;

			if (canLoad) {
				try {
					nextWaterRenderer = new CBumpWater();
				} catch (const content_error& ex) {
					delete nextWaterRenderer;
					nextWaterRenderer = NULL;
					LOG_L(L_ERROR, "Loading Bumpmapped Water failed, error: %s",
							ex.what());
				}
			}
		} break;

		case WATER_RENDERER_REFL_REFR: {
			const bool canLoad =
				GLEW_ARB_fragment_program &&
				GLEW_ARB_texture_rectangle;

			if (canLoad) {
				try {
					nextWaterRenderer = new CRefractWater();
				} catch (const content_error& ex) {
					delete nextWaterRenderer;
					nextWaterRenderer = NULL;
					LOG_L(L_ERROR, "Loading Refractive Water failed, error: %s",
							ex.what());
				}
			}
		} break;

		case WATER_RENDERER_REFLECTIVE: {
			const bool canLoad =
				GLEW_ARB_fragment_program &&
				ProgramStringIsNative(GL_FRAGMENT_PROGRAM_ARB, "ARB/water.fp");

			if (canLoad) {
				try {
					nextWaterRenderer = new CAdvWater();
				} catch (const content_error& ex) {
					delete nextWaterRenderer;
					nextWaterRenderer = NULL;
					LOG_L(L_ERROR, "Loading Reflective Water failed, error: %s",
							ex.what());
				}
			}
		} break;
	}

	if (nextWaterRenderer == NULL) {
		nextWaterRenderer = new CBasicWater();
	}

	configHandler->Set("ReflectiveWater", nextWaterRenderer->GetID());
	return nextWaterRenderer;
}