Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/world.html13
-rw-r--r--src/client/view.cc44
-rw-r--r--src/core/entity.cc5
-rw-r--r--src/core/entity.h5
-rw-r--r--src/core/gameserver.cc2
-rw-r--r--src/core/net.h2
-rw-r--r--src/game/game.cc4
-rw-r--r--src/game/ship.cc11
-rw-r--r--src/render/draw.cc11
-rw-r--r--src/render/dust.cc20
-rw-r--r--src/render/image.h3
-rw-r--r--src/render/jpgfile.cc32
-rw-r--r--src/render/pngfile.cc5
-rw-r--r--src/render/textures.cc30
-rw-r--r--src/render/tga.cc3
15 files changed, 133 insertions, 57 deletions
diff --git a/doc/world.html b/doc/world.html
index 3ead6fe..8e91ce5 100644
--- a/doc/world.html
+++ b/doc/world.html
@@ -303,15 +303,15 @@ color =0.5 0.5 0.8
[star]
</h3>
<p>
- A star is a spherical entity without texture and a default radius of 96. The star globe
+ A star is a spherical entity with a default radius of 96. The star globe
will be rendered fullbright and serve as the main source of light for the current system.
At the moment only one system light source is supported. If you define multiple stars,
- the last one will serve as light source.
+ the last one will serve as light source. Stars can have a texture.
<pre>
[star]
label=whitedwarf
name=White Dwarf
-; a slightly yellow colour
+; light yellow
color=1.0 1.0 0.9
</pre>
@@ -320,5 +320,12 @@ color=1.0 1.0 0.9
</h2>
<p>
Definition of the shopping list.
+
+<h2>
+ Textures
+</h2>
+<p>
+ The engine supports textures in the TGA, PNG and JPG file formats. The filename extension
+ should be lowercase and the texture should be in 24bit RGB or 32bit RGBA format.
</body>
</html>
diff --git a/src/client/view.cc b/src/client/view.cc
index 24cd72e..a737988 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -408,6 +408,14 @@ void draw_status()
Text::draw(4, video::height - Text::fontheight()*3-4, statestr);
}
+ core::Entity *target = targets::current();
+ float d = 0;
+ std::stringstream strdistance;
+
+ if (target) {
+ d = math::distance(core::localcontrol()->location(), target->state()->location()) - target->radius() - core::localcontrol()->radius();
+ }
+
if (draw_devinfo->value()) {
std::stringstream devinfo;
devinfo << std::fixed << std::setprecision(2)
@@ -417,24 +425,28 @@ void draw_status()
devinfo << "^Nthurst:^B " << core::localcontrol()->thrust() << " "
<< "^Nspeed:^B " << core::localcontrol()->speed() << '\n';
+ if (target)
+ devinfo << "^Ndist:^B " << d << '\n';
Text::draw(4, 4 + Text::fontheight(), devinfo);
}
float y = 1.0f;
- core::Entity *entity = targets::current();
- if (entity) {
- std::stringstream target;
- target << "^B" << entity->name() << "\n";
- target << "^Ndist ^B";
-
- math::Vector3f v = entity->state()->location() - core::localcontrol()->state()->location();
- float d = v.length() - entity->radius() - core::localcontrol()->radius();
- if (d > 0 )
- target << std::fixed << std::setprecision(2) << std::setfill(' ') << std::setw(8) << d;
- else
- target << " --";
-
- Text::draw(video::width - 4-Text::fontwidth()*32, video::height - Text::fontheight()*2 -4, target);
+ if (target) {
+ std::stringstream strtarget;
+ strtarget << "^B" << target->name() << "\n^B";
+
+ if (d > 0 ) {
+ strtarget << "^Ndist:^B ";
+ if (d > 100.0f) {
+ strtarget << roundf(d * 0.1f) << "km";
+ } else {
+ strtarget << roundf(d * 100.0f) << "m";
+ }
+ } else {
+ strtarget << " --";
+ }
+ strtarget << '\n';
+ Text::draw(video::width - 4-Text::fontwidth()*32, video::height - Text::fontheight()*2 -4, strtarget);
y = 3.0f;
}
@@ -460,6 +472,10 @@ void draw_status()
gl::end();
float u = core::localcontrol()->thrust();
+ if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ u = 1.0;
+ }
+
if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) {
if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 99462b8..0a6a201 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -371,6 +371,7 @@ EntityControlable::EntityControlable(Player *owner, unsigned int flags) :
EntityDynamic(flags)
{
entity_thrust = 0;
+ entity_movement = 0;
target_direction = 0.0f;
target_thrust = 0.0f;
@@ -388,6 +389,7 @@ EntityControlable::EntityControlable(std::istream & is) :
EntityDynamic(is)
{
entity_thrust = 0;
+ entity_movement = 0;
target_direction = 0.0f;
target_thrust = 0.0f;
@@ -452,6 +454,7 @@ void EntityControlable::serialize_server_update(std::ostream & os) const
{
EntityDynamic::serialize_server_update(os);
os << roundf(entity_thrust*100.0f) << " ";
+ os << roundf(entity_movement * 100.0f) << " ";
}
void EntityControlable::receive_server_update(std::istream &is)
@@ -459,6 +462,8 @@ void EntityControlable::receive_server_update(std::istream &is)
EntityDynamic::receive_server_update(is);
is >> entity_thrust;
entity_thrust /= 100.0f;
+ is >> entity_movement;
+ entity_movement /= 100.0f;
}
void EntityControlable::frame(float seconds)
diff --git a/src/core/entity.h b/src/core/entity.h
index 6214d50..180d535 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -311,6 +311,9 @@ public:
/// thrust
inline float thrust() const { return entity_thrust; }
+ /// movement indicator
+ inline float movement() const { return entity_movement; }
+
/*----- serializers ----------------------------------------------- */
/// serialize the entity to a stream
@@ -382,6 +385,8 @@ protected:
float target_strafe;
+ float entity_movement;
+
private:
// owner of the entity
Player *entity_owner;
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index ea97eaf..5e1165d 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -121,7 +121,7 @@ GameServer::GameServer() : GameInterface()
return;
}
- load_config();
+ //load_config(); //FIXME interferes with command line because of cmd.exec
// set the name of the game
core::Cvar::set("g_name", server_module->name().c_str(), core::Cvar::Game | core::Cvar::ReadOnly);
diff --git a/src/core/net.h b/src/core/net.h
index c96ec7e..f3f976b 100644
--- a/src/core/net.h
+++ b/src/core/net.h
@@ -11,7 +11,7 @@ namespace core
{
/// network protocol version
-const unsigned int PROTOCOLVERSION = 8;
+const unsigned int PROTOCOLVERSION = 9;
/// maximum lenght of a (compressed) network message block
const unsigned int FRAMESIZE = 1152;
diff --git a/src/game/game.cc b/src/game/game.cc
index 6b44c51..2c5b8cd 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -216,10 +216,10 @@ void Game::init()
g_impulsespeed = core::Cvar::get("g_impulsespeed", "15", core::Cvar::Game | core::Cvar::Archive);
g_impulsespeed->set_info("[float] speed of the impulse drive");
- g_impulseacceleration = core::Cvar::get("g_impulseacceleration", "4", core::Cvar::Game | core::Cvar::Archive);
+ g_impulseacceleration = core::Cvar::get("g_impulseacceleration", "5", core::Cvar::Game | core::Cvar::Archive);
g_impulseacceleration->set_info("[float] acceleration of the impulse drive");
- g_strafespeed = core::Cvar::get("g_strafespeed", "0.002", core::Cvar::Game | core::Cvar::Archive);
+ g_strafespeed = core::Cvar::get("g_strafespeed", "0.003", core::Cvar::Game | core::Cvar::Archive);
g_strafespeed->set_info("[float] strafe speed");
g_devel = core::Cvar::get("g_devel", "0", core::Cvar::Archive);
diff --git a/src/game/ship.cc b/src/game/ship.cc
index a5d64f3..167c82a 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -155,6 +155,8 @@ void Ship::frame(float seconds)
float actual_turnspeed = ship_shipmodel->turnspeed();
float actual_acceleration = ship_shipmodel->acceleration();
+ entity_movement = 0;
+
// speed might get set to 0 on this update
if (entity_speed != 0.0f)
entity_dirty = true;
@@ -388,10 +390,17 @@ void Ship::frame(float seconds)
entity_location += entity_axis.left() * (current_target_strafe * Game::instance()->g_strafespeed->value());
}
+ entity_movement = target_thrust;
+ entity_movement = math::max(entity_movement, fabs(current_target_pitch));
+ entity_movement = math::max(entity_movement, fabs(current_target_direction));
+ entity_movement = math::max(entity_movement, fabs(current_target_roll));
+ entity_movement = math::max(entity_movement, fabs(current_target_afterburner));
+ entity_movement = math::max(entity_movement, fabs(current_target_strafe));
+
if (entity_speed) {
entity_location += entity_axis.forward() * entity_speed * seconds;
entity_dirty = true;
- } else if ((current_target_pitch != 0.0f) || (current_target_direction != 0.0f) || (current_target_roll != 0.0f) || (current_target_afterburner != 0.0f) || (current_target_strafe != 0)) {
+ } else if (entity_movement > 0.0f) {
entity_dirty = true;
}
}
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 9c5a0d0..415a56c 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -855,8 +855,11 @@ void draw_pass_model_fx(float elapsed)
// draw model engines for Controlable entities
if ((entity->type() == core::Entity::Controlable) && entity->model()->engines().size()) {
-
- u = static_cast<core::EntityControlable *>(entity)->thrust();
+ core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
+ u = ec->thrust();
+ if ((ec->eventstate() == core::Entity::ImpulseInitiate) || (ec->eventstate() == core::Entity::Impulse)) {
+ u = 1;
+ }
if (u > 0) {
t = entity->state()->state_engine_trail_offset;
@@ -901,14 +904,14 @@ void draw_pass_model_fx(float elapsed)
Stats::quads++;
}
- if (!engine->notrail()) {
+ if (!(engine->notrail() || (ec->eventstate() == core::Entity::Impulse))) {
// draw the engine trail
if (current_texture != circle_texture) {
gl::end();
current_texture = Textures::bind(circle_texture);
gl::begin(gl::Quads);
}
- color.assign(1.0f, 1.0f);
+ color.assign(1.0f, 1.0f);
offset.assign(entity->state()->axis().forward() * engine_size);
if (t > 0)
diff --git a/src/render/dust.cc b/src/render/dust.cc
index 25df9f9..ad337b3 100644
--- a/src/render/dust.cc
+++ b/src/render/dust.cc
@@ -91,8 +91,9 @@ void Dust::draw()
return;
}
- if (! core::localcontrol()->speed())
- return;
+ alpha = math::max(core::localcontrol()->movement(), core::localcontrol()->speed());
+ math::clamp(alpha, 0.0f, 1.0f);
+ alpha = 0.2f + alpha * 0.8f;
if (!dust) {
con_debug << " generating dust..." << std::endl;
@@ -105,17 +106,10 @@ void Dust::draw()
dust[i*3+2] = core::localcontrol()->location().z + (math::randomf(2) - 1) * (DUSTDISTANCE + core::localcontrol()->radius());
}
}
-
- math::Color color(1.0f, 1.0f);
- alpha = core::localcontrol()->speed() / LOWSPEEDLIMIT;
- if (alpha > DUSTMAXALPHA)
- alpha = DUSTMAXALPHA;
- color.a = alpha;
-
- traillength = core::localcontrol()->speed() / LOWSPEEDLIMIT;
- /*if (traillength > 1)
- traillength = 1.0f; */
- traillength *= TRAILLENGHT;
+
+ math::Color color(1.0f, alpha);
+ traillength = math::max(math::max(core::localcontrol()->movement(), core::localcontrol()->speed()), 0.5f);
+ traillength = traillength * TRAILLENGHT / LOWSPEEDLIMIT;
gl::color(color);
gl::begin(gl::Lines);
diff --git a/src/render/image.h b/src/render/image.h
index c9cc029..3c82792 100644
--- a/src/render/image.h
+++ b/src/render/image.h
@@ -35,6 +35,9 @@ public:
/// number of channels 3 (RGB) or 4 (RGBA)
inline unsigned int channels() const { return image_channels; }
+ /// bits per pixel
+ inline unsigned int bpp() const { return (image_channels * 8); }
+
/// set image data to zero
void clear();
diff --git a/src/render/jpgfile.cc b/src/render/jpgfile.cc
index 74cdea9..872233f 100644
--- a/src/render/jpgfile.cc
+++ b/src/render/jpgfile.cc
@@ -26,6 +26,10 @@ namespace render {
Image *JPG::load(const char *filename)
{
+ struct jpeg_decompress_struct jpeg_decompression_info;
+ struct jpeg_error_mgr jerr;
+
+ int row_stride = 0;
Image *image = 0;
if (!filename)
@@ -36,12 +40,34 @@ Image *JPG::load(const char *filename)
//con_warn << "Could not open " << filename << std::endl;
return 0;
}
+
+ // initialize decompression structures
+ jpeg_decompression_info.err = jpeg_std_error(&jerr);
+ jpeg_create_decompress(&jpeg_decompression_info);
+ jpeg_stdio_src(&jpeg_decompression_info, jpg_file->handle());
+
+ // read JPEG header
+ jpeg_read_header(&jpeg_decompression_info, TRUE);
+ jpeg_start_decompress(&jpeg_decompression_info);
+
+ row_stride = jpeg_decompression_info.output_width * jpeg_decompression_info.output_components;
+ image = new Image(jpeg_decompression_info.output_width,
+ jpeg_decompression_info.output_height,
+ jpeg_decompression_info.output_components);
+
+ // read pixel data
+ JSAMPLE *row_pointer;
+ while (jpeg_decompression_info.output_scanline < jpeg_decompression_info.output_height) {
+ row_pointer = (*image)[jpeg_decompression_info.output_scanline*row_stride];
+ jpeg_read_scanlines(&jpeg_decompression_info, &row_pointer, 1);
+ }
+ jpeg_finish_decompress(&jpeg_decompression_info);
-
+ // destroy decompression structures
+ jpeg_destroy_decompress(&jpeg_decompression_info);
filesystem::close(jpg_file);
-// con_debug << " " << filename << " " << png_width << "x" << png_height << "x" << channels * png_depth << "bpp" << std::endl;
-
+ con_debug << " " << filename << " " << image->width() << "x" << image->height() << "x" << image->bpp() << "bpp" << std::endl;
return image;
}
diff --git a/src/render/pngfile.cc b/src/render/pngfile.cc
index bff6a54..d011aff 100644
--- a/src/render/pngfile.cc
+++ b/src/render/pngfile.cc
@@ -110,14 +110,13 @@ Image *PNG::load(const char *filename)
for (size_t i=0; i < (size_t)png_height; i++)
row_pointers[i] = (png_bytep) (*image)[i * info_ptr->rowbytes];
+ // read pixel data
png_read_image(png_ptr, row_pointers);
filesystem::close(png_file);
-
- con_debug << " " << filename << " " << png_width << "x" << png_height << "x" << channels * png_depth << "bpp" << std::endl;
-
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
+ con_debug << " " << filename << " " << image->width() << "x" << image->height() << "x" << image->bpp() << "bpp" << std::endl;
return image;
}
diff --git a/src/render/textures.cc b/src/render/textures.cc
index 6ceb7cd..a041c32 100644
--- a/src/render/textures.cc
+++ b/src/render/textures.cc
@@ -10,6 +10,7 @@
#include "render/textures.h"
#include "render/tga.h"
#include "render/pngfile.h"
+#include "render/jpgfile.h"
#include "sys/sys.h"
#include "core/application.h"
@@ -76,23 +77,32 @@ size_t Textures::load(std::string name, bool filter)
std::string filename;
Image *image = 0;
- // try the png version
- filename.assign(name);
- filename.append(".png");
- image = PNG::load(filename.c_str());
+ if (!image) {
+ // try the png version
+ filename.assign(name);
+ filename.append(".png");
+ image = PNG::load(filename.c_str());
+ }
if (!image) {
// try the tga version
filename.assign(name);
filename.append(".tga");
image = TGA::load(filename.c_str());
+ }
+
+ if (!image) {
+ // try the jpg version
+ filename.assign(name);
+ filename.append(".jpg");
+ image = JPG::load(filename.c_str());
+ }
- if (!image) {
- // add to the registry with id 0 (texture not found)
- con_warn << "Could not open " << filename << std::endl;
- registry[name] = 0;
- return 0;
- }
+ if (!image) {
+ // add to the registry with id 0 (texture not found)
+ con_warn << "Could not open " << filename << std::endl;
+ registry[name] = 0;
+ return 0;
}
size_t id = index;
diff --git a/src/render/tga.cc b/src/render/tga.cc
index 9703ce8..d9e5cb2 100644
--- a/src/render/tga.cc
+++ b/src/render/tga.cc
@@ -211,8 +211,7 @@ Image *TGA::load(const char *filename)
con_warn << filename << ": descriptor bit 4 (left-right) set!" << std::endl;
}
- con_debug << " " << filename << " " << tga_width << "x" << tga_height << "x" << tga_depth << "bpp" << std::endl;
-
+ con_debug << " " << filename << " " << image->width() << "x" << image->height() << "x" << image->bpp() << "bpp" << std::endl;
return image;
}