diff options
| -rw-r--r-- | doc/ROADMAP | 75 | ||||
| -rw-r--r-- | doc/TODO | 20 | ||||
| -rw-r--r-- | src/audio/audio.cc | 2 | ||||
| -rw-r--r-- | src/client/input.cc | 43 | ||||
| -rw-r--r-- | src/client/keyboard.cc | 22 | ||||
| -rw-r--r-- | src/client/keyboard.h | 4 | ||||
| -rw-r--r-- | src/game/game.cc | 15 | ||||
| -rw-r--r-- | src/game/game.h | 6 | ||||
| -rw-r--r-- | src/game/ship.cc | 4 | ||||
| -rw-r--r-- | src/math/functions.h | 7 | ||||
| -rw-r--r-- | src/math/vector3f.cc | 4 | ||||
| -rw-r--r-- | src/model/map.cc | 9 | ||||
| -rw-r--r-- | src/model/material.h | 2 | ||||
| -rw-r--r-- | src/render/camera.cc | 33 | ||||
| -rw-r--r-- | src/render/camera.h | 5 | ||||
| -rw-r--r-- | src/render/draw.cc | 38 | 
16 files changed, 222 insertions, 67 deletions
diff --git a/doc/ROADMAP b/doc/ROADMAP index 24a3643..3bd3dfd 100644 --- a/doc/ROADMAP +++ b/doc/ROADMAP @@ -1,6 +1,10 @@ -ROADMAP -* MILESTONE 1 - version 0.1 + +The Osirion Project - ROADMAP + +  ------------------------------------------------------------------ + +* MILESTONE 1 - version 0.1 - The Universe  Description:  	The game takes place in a simple solar system with one star, @@ -11,40 +15,65 @@ Description:  	fly around and see each other. They can use chat to communicate,   	they can use private chat or global chat. +	The game world is divided into zones, the zones can be populated +	with entities. Players can jump between zones. +  Requires: -	Client console -	Entities -	Ship instances -	Network subsystem -	Entities -	Camera handling -	Keyboard bindings +	client console +	entities +	ship instances +	network subsystem +	entities +	camera handling +	keyboard bindings +	zones +	basic travelling -* MILESTONE 2 - version 0.2 +  ------------------------------------------------------------------ + +* MILESTONE 2 - version 0.2 - Interaction  Description: +	Players can dock at a space station, planets or large ships. Docking +	a jumpgate enables hyperspace travel for smaller ships. +	  	Players can shoot at each other. They can crash into the star   	or the planet. Player ships explode on destruction.  Requires: -	Targetting -	Events: explosions, weapons fire -	Model weapon support -	Turret and cannon models -	Particle systems +	basic docking +	basic docking gui +	targetting +	events: explosions, weapons fire, sounds +	weapon support +	turret and cannon models +	particle systems  	clip brushes and collision detection -* MILESTONE 3 - version 0.3 +  ------------------------------------------------------------------ -Description: -	Players can dock at the space station and buy a ship or purchase -	weapons. +* MILESTONE 3 - version 0.3 - Commodities +Description: +	Players can buy and sell cargo at dockable entities. +	  Requires: -	Docking -	Docking GUI +	player credits +	enhanced docking +	enhanced docking gui +	commodities market +	fuel system? -* MILESTONE 4 - version 0.4 +  ------------------------------------------------------------------ + +* MILESTONE 4 - version 0.4 - Equipment + +Description: +	Players can buy and sell ship and equipment. + +Requires: +	ship market +	equipment market  * MILESTONE 5 @@ -52,6 +81,8 @@ Requires:  .. +  ------------------------------------------------------------------ +  * Release 1.0  Requires: @@ -2,14 +2,15 @@ TODO  milestone 1:  	fix turning (needs more testing) -	fix cl_prediction +	fix cl_prediction (or not) +	fix autolevel  milestone 2:  	zones  	targetting system  	server-client event system, hit-once lightweight entities  	explosion events -	weapon fire events +	weapons fire events  milestone 3:  	gui @@ -37,11 +38,10 @@ core:  	refactor 'say', it should not be a game function (ok)  	execute config files (ok)  	support entity secondairy color (ok) +	toggle func to toggle a bool cvar (ok) -	zones (breaks network proto)  	game module loading/unloading (breaks network proto, server must send module type) -	 -	toggle func to toggle a bool cvar +	zone changes, clear entities  network:  	UDP datagrams (ok) @@ -57,6 +57,8 @@ network:  	group/clan chat (requires groups)  	rcon authentication, rcon command, servers must be able to disable rcon +	zone changes +	send clients only updates from the current zone  	fix lag/client interpolation  	rename cl_prediction to cl_interpolation  	detect and disconnect clients behaving badly @@ -69,10 +71,12 @@ client:  	better crosshair bitmaps (ok)  	keyboard repeat (ok)  	fix tracking camera (ok) +	shift/ctrl/alt modifier key binds (ok)  	fix camera frustum clip (size issue, postponed) -	shift/ctrl/alt modifier key binds	 +	view_next, view_prev (ok) +	mouse select on release event while   render:  	render pipeline (ok) @@ -83,6 +87,7 @@ render:  	test/fix? lighting without sun in world.ini  	sun light strenght +	skysphere distortion at the poles  gui:  	a gui library with widgets and buttons @@ -99,7 +104,8 @@ game:  	entity health/shield/armor  	gui concept artwork  	docking -	jumpgates, requires zones +	jumpgates (required docking) +	fix autolevel  win32 port:  	network not functional (ok) diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 3ad640d..94f4d23 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -115,7 +115,7 @@ void loop( size_t source_index, const char *name, float pitch, float gain)  	ALuint source = Sources::source(source_index);  	Buffers::bind(source, Buffers::load(std::string(name))); -	alSourcef(source, AL_REFERENCE_DISTANCE, 2.0f); +	//alSourcef(source, AL_REFERENCE_DISTANCE, 2.0f); // might be the cause of cracks in the sound  	alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);  	alSourcef(source, AL_PITCH, pitch);      	alSourcef(source, AL_GAIN, gain); diff --git a/src/client/input.cc b/src/client/input.cc index 044ebc2..2f09d5b 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -104,10 +104,21 @@ void func_ui_chat(std::string const &args)  	}  } -void func_ui_view(std::string const &args) +void func_view_next(std::string const &args)  {  	if (core::application()->connected() && core::localcontrol()) { -		render::Camera::next_mode(); +		render::Camera::view_next(); +		local_roll = 0; +		local_pitch = 0; +		local_direction = 0; +		audio::play("ui/view"); +	} +} + +void func_view_prev(std::string const &args) +{ +	if (core::application()->connected() && core::localcontrol()) { +		render::Camera::view_previous();  		local_roll = 0;  		local_pitch = 0;  		local_direction = 0; @@ -227,9 +238,6 @@ void init()  	func = core::Func::add("ui_chat", func_ui_chat);  	func->set_info("toggle chatbox on or of"); -	func = core::Func::add("ui_view", func_ui_view); -	func->set_info("switch camera view"); -  	func = core::Func::add("ui_control",func_ui_control);  	func->set_info("toggle mouse control"); @@ -251,6 +259,12 @@ void init()  	func = core::Func::add("unbindall", func_unbind);  	func->set_info("unbind all keys"); +	func = core::Func::add("view_next", func_view_next); +	func->set_info("switch to next view"); + +	func = core::Func::add("view_prev", func_view_prev); +	func->set_info("switch to previous view"); +  	func = core::Func::add("screenshot", func_screenshot);  	func->set_info("make a screenshot"); @@ -406,8 +420,21 @@ Key::Modifier convert_SDL_modifier(int const sdlmodifier)  void key_pressed(Key *key)  { -	if ((key->sym() == SDLK_ESCAPE) || (key->bind(Key::None).compare("ui_console") == 0)) { -		console()->toggle(); +	if (key->sym() == SDLK_ESCAPE) { +		if (chat::visible()) { +			chat::toggle(); +		} else { +			local_direction = 0.0f; +			local_pitch = 0.0f; +			local_roll = 0.0f; + +			render::Camera::set_direction(0.0f); +			render::Camera::set_pitch(0.0f); + +			console()->toggle(); +		} + +	} else if (key->bind(Key::None).compare("ui_console") == 0) {  		local_direction = 0.0f;  		local_pitch = 0.0f;  		local_roll = 0.0f; @@ -415,6 +442,8 @@ void key_pressed(Key *key)  		render::Camera::set_direction(0.0f);  		render::Camera::set_pitch(0.0f); +		console()->toggle(); +  	} else if (console()->visible()) {  		// send key events to the console  		if (key->sym() < 512) diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc index e0c5642..791e6df 100644 --- a/src/client/keyboard.cc +++ b/src/client/keyboard.cc @@ -52,6 +52,7 @@ Keyboard::Keyboard()  	add_action("+control", Action::None, "enable mouse control while pressed");  	// ------------------ KEYS +	Key *key = 0;  	add_key("backspace", SDLK_BACKSPACE);  	add_key("tab", SDLK_TAB); @@ -113,15 +114,18 @@ Keyboard::Keyboard()  	add_key("k", SDLK_k, 'k');  	add_key("l", SDLK_l, 'l');  	add_key("m", SDLK_m, 'm'); -	add_key("n", SDLK_n, 'n', "target_next"); +	key = add_key("n", SDLK_n, 'n', "target_next"); +	key->assign(Key::Shift, "target_prev");  	add_key("o", SDLK_o, 'o'); -	add_key("p", SDLK_p, 'p', "target_prev"); +	add_key("p", SDLK_p, 'p');  	add_key("q", SDLK_q, 'q');  	add_key("r", SDLK_r, 'r');  	add_key("s", SDLK_s, 's');  	add_key("t", SDLK_t, 't', "ui_chat");  	add_key("u", SDLK_u, 'u'); -	add_key("v", SDLK_v, 'v', "ui_view"); +	key = add_key("v", SDLK_v, 'v', "view_next"); +	key->assign(Key::Shift, "view_prev"); +  	add_key("w", SDLK_w, 'w');  	add_key("x", SDLK_x, 'x');  	add_key("y", SDLK_y, 'y'); @@ -423,14 +427,18 @@ void Keyboard::unbindall()  	}  } -void Keyboard::add_key(const char *name, const unsigned int keysym, const char ascii, const char *bind) +Key * Keyboard::add_key(const char *name, const unsigned int keysym, const char ascii, const char *bind)  { -	keys[keysym] = new Key(name, keysym, ascii, bind); +	Key *newkey = new Key(name, keysym, ascii, bind); +	keys[keysym] =  newkey; +	return newkey;  } -void Keyboard::add_action(const char *name, Action::Identifier action, const char *info) +Action * Keyboard::add_action(const char *name, Action::Identifier action, const char *info)  { -	actions.push_back(new Action(name, action, info)); +	Action *newaction = new Action(name, action, info); +	actions.push_back(newaction); +	return newaction;  }  void Keyboard::list_actions() diff --git a/src/client/keyboard.h b/src/client/keyboard.h index 2841495..87a67c4 100644 --- a/src/client/keyboard.h +++ b/src/client/keyboard.h @@ -70,9 +70,9 @@ public:  	inline iterator end() { return keys.end(); }  private: -	void add_key(const char *name, const unsigned int keysym, const char ascii=0, const char *bind=0); +	Key *add_key(const char *name, const unsigned int keysym, const char ascii=0, const char *bind=0); -	void add_action(const char *name, Action::Identifier action, const char *info = 0); +	Action *add_action(const char *name, Action::Identifier action, const char *info = 0);  	std::map<unsigned int, Key *> keys;  	std::list<Action *> actions; diff --git a/src/game/game.cc b/src/game/game.cc index e481c9f..83daa93 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -20,7 +20,7 @@  namespace game  { -Game 			*this_game = 0; +  ShipModel		*default_shipmodel = 0;  core::Zone		*default_zone = 0; @@ -183,15 +183,19 @@ void func_jump(core::Player *player, std::string const &args)  	player->set_zone(zone);  } -/*----- Game ------------------------------------------------------ */ +/* ---- The Game class --------------------------------------------- */ + +Game 			*Game::game_instance = 0;  Game::Game() : core::Module("Project::OSiRiON")  { -	this_game = this; +	game_instance = this; +	g_autolevel = 0;  }  Game::~Game()  { +	game_instance = 0;  }  void Game::init() @@ -227,8 +231,8 @@ void Game::init()  	func = core::Func::add("list_ship", (core::FuncPtr) func_list_ship);  	func->set_info("list ship statistics"); -	// set game variables -	core::Cvar::set("g_impulsespeed", "10.0f", core::Cvar::Game); +	g_autolevel = core::Cvar::get("g_autolevel", "1", core::Cvar::Game | core::Cvar::Archive); +	g_autolevel->set_info("[bool] enable or disale experimental autolevelling");  	// indicate the module is ready to run frames  	module_running = true; @@ -236,6 +240,7 @@ void Game::init()  void Game::shutdown()  { +	g_autolevel = 0;  	// game functions are automaticly removed  	// remove engine core functions diff --git a/src/game/game.h b/src/game/game.h index a715edd..3d8e3b9 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -48,12 +48,18 @@ public:  	/// is called when a player disconnects  	void player_disconnect(core::Player *player); +	static inline Game *instance() { return game_instance; } + +	core::Cvar *g_autolevel; +  private:  	bool load_world();  	bool load_zone(core::Zone *zone);  	bool load_ships(); + +	static Game *game_instance;  };  } diff --git a/src/game/ship.cc b/src/game/ship.cc index d8f7bb3..aa47044 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -64,7 +64,7 @@ void Ship::frame(float seconds)  	entity_thrust = target_thrust; -	if (autolevel()) { +	if (autolevel() && Game::instance()->g_autolevel->value()) {  		n.assign(math::crossproduct(entity_axis.up(), math::Vector3f(0, 0, 1.0f)));  		if (!(n.length() < MIN_DELTA)) {  			cosangle = math::dotproduct(entity_axis.up(), math::Vector3f(0, 0, 1.0f)); @@ -96,7 +96,7 @@ void Ship::frame(float seconds)  	}  	// auto-leveling -	if (autolevel()) { +	if (autolevel()  && Game::instance()->g_autolevel->value()) {  		n.assign(math::crossproduct(entity_axis.up(), math::Vector3f(0.0f, 0.0f, 1.0f)));  		if (!(n.length() < MIN_DELTA)) {  			cosangle = math::dotproduct(entity_axis.up(), math::Vector3f(0.0f, 0.0f, 1.0f)); diff --git a/src/math/functions.h b/src/math/functions.h index 3d5d056..be6919d 100644 --- a/src/math/functions.h +++ b/src/math/functions.h @@ -49,9 +49,12 @@ float degrees180f(float angle);  float degrees360f(float angle);  /// clamp a float to a specified range -inline void clamp(float &value, float min=0.0f, float max=1.0f) +inline void clamp(float &value, const float min=0.0f, const float max=1.0f)  { -	if (value < min) value = min; else if (value > max) value = max; +	if (value < min)  +		value = min;  +	else if (value > max)  +		value = max;  }  /// return the absolute value of a float diff --git a/src/math/vector3f.cc b/src/math/vector3f.cc index d5173bb..57ad52a 100644 --- a/src/math/vector3f.cc +++ b/src/math/vector3f.cc @@ -49,7 +49,9 @@ void Vector3f::assign(const float vx, const float vy, const float vz)  void Vector3f::assign(Vector3f const & other)  { -	memcpy(coord, other.coord, sizeof(coord)); +	coord[0] = other.coord[0]; +	coord[1] = other.coord[1]; +	coord[2] = other.coord[2];  }  Vector3f & Vector3f::operator=(const Vector3f & other) diff --git a/src/model/map.cc b/src/model/map.cc index c68bb1d..2930021 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -479,6 +479,10 @@ void Map::make_brushface(Plane *face)  		} else if (face->texture().compare("common/entity_thirdy_dark") == 0) {  			material |= Material::Tertiary;  			material |= Material::Dark; +		 +		} else if (face->texture().compare("common/engine") == 0) { +			color.assign(1, 0, 0); +			material |= Material::Engine;  		}  		// translate surface flags to materials @@ -487,6 +491,11 @@ void Map::make_brushface(Plane *face)  		if ((face->surface_flags() & 1) == 1) {  			material |= Material::Light;  		} + +		// surface flag 2 engine +		if ((face->surface_flags() & 2) == 2) { +			material |= Material::Engine; +		}  		// find the list if primitives for the current material, allocate a new one if necessary  		Primitives *primitives = 0; diff --git a/src/model/material.h b/src/model/material.h index 02ae58f..bdfee68 100644 --- a/src/model/material.h +++ b/src/model/material.h @@ -13,7 +13,7 @@ namespace model  class Material  {  public: -	enum Flags { None=0, Primary=1, Secondary=2, Tertiary=3, Dark=4, Light=8, Reflective=16 }; +	enum Flags { None=0, Primary=1, Secondary=2, Tertiary=3, Dark=4, Light=8, Engine=16};  };  } diff --git a/src/render/camera.cc b/src/render/camera.cc index 74eb674..283f40f 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -126,7 +126,7 @@ void Camera::set_mode(Mode newmode) {  } -void Camera::next_mode() +void Camera::view_next()  {   	if (!core::localcontrol()) { @@ -158,6 +158,37 @@ void Camera::next_mode()  	}  } +void Camera::view_previous() +{ +	 + 	if (!core::localcontrol()) { +		set_mode(Overview); +		return; +	} + +	switch(camera_mode) { +	case Cockpit: +		// switch camera to Track mode +		set_mode(Track); +		core::application()->notify_message(std::string("view: track")); +		break; + +	case Free: +		// switch camera to Cockpit mode +		set_mode(Cockpit); +		core::application()->notify_message(std::string("view: cockpit")); +		break; +	 +	case Track: +		// switch camera to Free mode +		set_mode(Free); +		core::application()->notify_message(std::string("view: free")); +		break; +	 +	default: +		break; +	} +}  void Camera::frame(float seconds)   {	  	math::Axis target_axis; diff --git a/src/render/camera.h b/src/render/camera.h index 253661f..db2db42 100644 --- a/src/render/camera.h +++ b/src/render/camera.h @@ -56,7 +56,10 @@ public:  	static void set_pitch(float pitch);  	/// switch to next camera mode -	static void next_mode(); +	static void view_next(); + +	/// wtich to previous camera mode +	static void view_previous();  	/// set specified camera mode  	static void set_mode(Mode newmode); diff --git a/src/render/draw.cc b/src/render/draw.cc index ee42bb6..4399c60 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -285,6 +285,11 @@ void draw_model_fragments(core::Entity *entity)  	bool use_color_array = true;	// glEnableClientState(GL_COLOR_ARRAY) is set  	bool use_light = true;		// gl::disable(GL_LIGHTING) is set +	float thrust = 0; +	if (entity->type() == core::Entity::Controlable) { +		thrust = static_cast<core::EntityControlable *>(entity)->thrust(); +	} +  	for (Model::Fragments::iterator fit = model->fragments().begin(); fit != model->fragments().end(); fit++) {  		Fragment *fragment = (*fit); @@ -292,7 +297,16 @@ void draw_model_fragments(core::Entity *entity)  		if (fragment->material() != material) {  			material = fragment->material(); -			if (material & Material::Tertiary) { +			if (material & Material::Engine) { + +				if (use_color_array) { +					glDisableClientState(GL_COLOR_ARRAY); +					use_color_array = false; +				} + +				gl::color(thrust, 0.0f, 0.0f); + +			} else if (material & Material::Tertiary) {  				if (use_color_array) {  					use_color_array = false;  					glDisableClientState(GL_COLOR_ARRAY); @@ -328,6 +342,11 @@ void draw_model_fragments(core::Entity *entity)  					gl::disable(GL_LIGHTING);  					use_light = false;  				} +			} else if (material & Material::Engine) { +				if (use_light) { +					gl::disable(GL_LIGHTING); +					use_light = false; +				}  			} else {  				if (!use_light) {  					gl::enable(GL_LIGHTING); @@ -616,7 +635,10 @@ void draw_pass_model_fx(float elapsed)  	float trail_size = 0.0f;  	math::Vector3f quad[4]; +	math::Vector3f location; +	math::Vector3f offset;  	math::Color color; +  	size_t circle_texture = Textures::load("bitmaps/fx/circle00");  	size_t flare_texture = Textures::bind("bitmaps/fx/flare00"); @@ -638,8 +660,8 @@ void draw_pass_model_fx(float elapsed)  				if (light->strobe())  					t = (core::application()->time() + entity->state()->fuzz() - light->offset()) * light->frequency(); -				if (!light->strobe() || (( t - floorf(t)) <= light->time())) { -					math::Vector3f location = entity->state()->location() + (entity->state()->axis() * light->location()); +				if ((!light->strobe()) || (( t - floorf(t)) <= light->time())) { +					location.assign(entity->state()->location() + (entity->state()->axis() * light->location()));  					light_size = 0.0625 * light->radius();  					if (flare_texture != light->texture()) { @@ -681,12 +703,12 @@ void draw_pass_model_fx(float elapsed)  				if (flare->strobe())  					t = (core::application()->time() + entity->state()->fuzz() - flare->offset()) * flare->frequency(); -				if (!flare->strobe() || (( t - floorf(t)) <= flare->time())) { +				if ((!flare->strobe()) || (( t - floorf(t)) <= flare->time())) {  					math::Axis flare_axis(entity->state()->axis());  					if (flare->angle())  						flare_axis.change_direction(flare->angle()); -					math::Vector3f location = entity->state()->location() + (entity->state()->axis() * flare->location()); +					location.assign(entity->state()->location() + (entity->state()->axis() * flare->location()));  					light_size = 0.0625 * flare->radius();  					if (flare_texture != flare->texture()) { @@ -740,9 +762,9 @@ void draw_pass_model_fx(float elapsed)  						model::Engine *engine = (*eit); -						math::Vector3f location = entity->state()->location() + (entity->state()->axis() * engine->location()); +						location.assign(entity->state()->location() + (entity->state()->axis() * engine->location()));  						engine_size = 0.0625 * engine->radius(); -						math::Color color(engine->color()); +						color.assign(engine->color());  						color.a = 0.9f * u;  						if (flare_texture != engine->texture() ) { @@ -774,7 +796,7 @@ void draw_pass_model_fx(float elapsed)  							gl::begin(gl::Quads);  						}  						color.assign(1.0f, 1.0f); -						math::Vector3f offset = entity->state()->axis().forward() * engine_size; +						offset.assign(entity->state()->axis().forward() * engine_size);  						if (t)  							location -= offset * t;  | 
