Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--osirion.kdevelop2
-rw-r--r--osirion.kdevelop.pcsbin561248 -> 579707 bytes
-rw-r--r--osirion.kdevses15
-rw-r--r--src/client/camera.cc4
-rw-r--r--src/client/camera.h3
-rw-r--r--src/client/view.cc2
-rw-r--r--src/core/entity.cc14
-rw-r--r--src/core/gameserver.cc6
-rw-r--r--src/core/netclient.cc5
-rw-r--r--src/core/netserver.cc2
-rw-r--r--src/game/ship.cc8
-rw-r--r--src/math/axis.cc10
-rw-r--r--src/math/axis.h3
-rw-r--r--src/render/draw.cc100
-rw-r--r--src/render/draw.h2
-rw-r--r--src/render/render.cc5
16 files changed, 123 insertions, 58 deletions
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 475045a..58a8bfc 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/math/libmath.la</activetarget>
+ <activetarget>src/client/libclient.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index b532052..ded2355 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index 8674cfa..a1c17a4 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,10 +1,19 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="1" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/sys/sys.cc" >
- <View0 Encoding="" line="30" Type="Source" />
+ <DocsAndViews NumberOfDocuments="4" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/camera.cc" >
+ <View0 Encoding="" line="160" Type="Source" />
</Doc0>
+ <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/entity.cc" >
+ <View0 Encoding="" line="203" Type="Source" />
+ </Doc1>
+ <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/ship.cc" >
+ <View0 Encoding="" line="40" Type="Source" />
+ </Doc2>
+ <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netclient.cc" >
+ <View0 Encoding="" line="0" Type="Source" />
+ </Doc3>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/client/camera.cc b/src/client/camera.cc
index d264ddf..e2dbacf 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -25,6 +25,7 @@ namespace camera
// gameworld coordinates of the camera target
math::Vector3f target;
math::Vector3f eye;
+math::Axis axis;
// target yaw, angle in XZ plane, positive is looking left
float yaw_target;
@@ -130,7 +131,6 @@ void next_mode()
void draw(float elapsed)
{
math::Matrix4f matrix;
- math::Axis axis;
float d = 0;
@@ -158,7 +158,7 @@ void draw(float elapsed)
if (mode == Track) {
// make the camera swing while turning
- yaw_target = 25 * core::localcontrol()->target_direction;
+ yaw_target = -25.0f * core::localcontrol()->target_direction;
pitch_target = pitch_track - 25 * core::localcontrol()->target_pitch;
}
diff --git a/src/client/camera.h b/src/client/camera.h
index 2a79fda..25e179d 100644
--- a/src/client/camera.h
+++ b/src/client/camera.h
@@ -47,6 +47,9 @@ namespace camera
/// gameworld coordinates of the camera eye
extern math::Vector3f eye;
+ /// global camera axis coordinate system
+ extern math::Axis axis;
+
/// current camera mode
extern Mode mode;
diff --git a/src/client/view.cc b/src/client/view.cc
index 39cd351..6f5ceca 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -268,7 +268,7 @@ void frame(float seconds)
camera::draw(seconds); // draw the current camera transformation
- render::draw(camera::eye, camera::target, seconds); // draw the world
+ render::draw(camera::axis, camera::eye, camera::target, seconds); // draw the world
}
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 475af39..b186c64 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -231,13 +231,19 @@ void EntityDynamic::recieve_client_update(std::istream &is)
void EntityDynamic::serialize_server_update(std::ostream & os) const
{
- os << entity_location << " " << entity_axis << " " << entity_speed;
+ os << entity_location << " ";
+ os << entity_axis.forward() << " ";
+ os << entity_axis.left() << " ";
+ os << entity_axis.up() << " ";
+ os << entity_speed;
}
void EntityDynamic::recieve_server_update(std::istream &is)
{
is >> entity_location;
- is >> entity_axis;
+ is >> entity_axis[0];
+ is >> entity_axis[1];
+ is >> entity_axis[2];
is >> entity_speed;
}
@@ -253,6 +259,7 @@ EntityControlable::EntityControlable(Player *player, unsigned int flags) :
target_direction = 0.0f;
target_thrust = 0.0f;
+ target_pitch = 0.0f;
}
EntityControlable::EntityControlable(std::istream & is) :
@@ -285,13 +292,16 @@ void EntityControlable::serialize_client_update(std::ostream & os) const
{
EntityDynamic::serialize_client_update(os);
os << " " << target_direction;
+ os << " " << target_pitch;
os << " " << target_thrust;
+
}
void EntityControlable::recieve_client_update(std::istream &is)
{
EntityDynamic::recieve_client_update(is);
is >> target_direction;
+ is >> target_pitch;
is >> target_thrust;
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 1aa57f0..2169e21 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -143,7 +143,7 @@ void GameServer::say(Player *player, std::string const &message)
con_print <<player->name() << ": " << message << "\n";
// broadcast to remote clients
- if (server_network != 0 ) {
+ if (server_network) {
std::string netmessage("msg public ");
netmessage.append(player->name());
netmessage.append(": ");
@@ -286,12 +286,14 @@ void GameServer::frame(float seconds)
if (entity->entity_destroyed) {
if (!entity->entity_created) {
std::ostringstream netmsg;
+ netmsg.str("");
netmsg << "die " << entity->id() << "\n";
server_network->broadcast(netmsg.str());
}
core::Entity::remove(entity->id());
} else if (entity->entity_created) {
std::ostringstream netmsg;
+ netmsg.str("");
netmsg << "ent ";
entity->serialize(netmsg);
netmsg << "\n";
@@ -300,9 +302,11 @@ void GameServer::frame(float seconds)
} else if (entity->dirty()) {
std::ostringstream netmsg;
+ netmsg.str("");
netmsg << "sup " << entity->id() << " ";
entity->serialize_server_update(netmsg);
netmsg << "\n";
+ netmsg.flush();
server_network->broadcast(netmsg.str());
}
entity->entity_dirty = false;
diff --git a/src/core/netclient.cc b/src/core/netclient.cc
index c910e26..0c0d72a 100644
--- a/src/core/netclient.cc
+++ b/src/core/netclient.cc
@@ -121,7 +121,6 @@ void NetClient::send(std::string const &msg)
void NetClient::transmit(int serverfd)
{
-
if (!sendq.size()) {
if (client_keepalive + NETTIMEOUT/2 < application()->time()) {
sendq.assign("ping\n");
@@ -129,7 +128,7 @@ void NetClient::transmit(int serverfd)
return;
}
} else if (sendq.size() >= FRAMESIZE) {
- con_warn << "Outgoing message exceeds " << FRAMESIZE << " bytes!\n";
+ con_warn << "Outgoing message exceeds " << FRAMESIZE -1 << " bytes!\n";
//sendq.clear();
//return;
}
@@ -137,7 +136,7 @@ void NetClient::transmit(int serverfd)
ssize_t bytes_sent = 0;
while (sendq.size() && !error()) {
- bytes_sent = ::sendto(serverfd, sendq.c_str(), sendq.size(), 0,
+ bytes_sent = ::sendto(serverfd, sendq.c_str(), sendq.size()+1, 0,
(struct sockaddr *)&client_addr, sizeof(client_addr));
if (bytes_sent < 0) {
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 8b9cbe5..064229b 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -178,7 +178,7 @@ void NetServer::receive()
timeval timeout;
timeout.tv_sec = 0;
- timeout.tv_usec = 0;
+ timeout.tv_usec = 25000;
fd_set readset = serverset;
int nb = select(fd()+1, &readset, NULL, NULL, &timeout);
diff --git a/src/game/ship.cc b/src/game/ship.cc
index c9e2266..538a1e6 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -48,9 +48,9 @@ void Ship::frame(float seconds)
else if (target_pitch < -1.0f)
target_pitch = -1.0f;
- float pitch_offset = ship_shipmodel->turnspeed() * seconds * target_pitch;
+ float pitch_offset = seconds * target_pitch;
if (pitch_offset)
- entity_axis.change_pitch(360.0f * pitch_offset);
+ entity_axis.change_pitch(360.0f * ship_shipmodel->turnspeed() * pitch_offset);
// update direction
if (target_direction > 1.0f)
@@ -58,9 +58,9 @@ void Ship::frame(float seconds)
else if (target_direction < -1.0f)
target_direction = -1.0f;
- float direction_offset = ship_shipmodel->turnspeed() * seconds * target_direction;
+ float direction_offset = seconds * target_direction;
if (direction_offset)
- entity_axis.change_direction(360.0f * direction_offset);
+ entity_axis.change_direction(360.0f * ship_shipmodel->turnspeed() * direction_offset);
// update speed
if (entity_speed < entity_thrust * ship_shipmodel->maxspeed()) {
diff --git a/src/math/axis.cc b/src/math/axis.cc
index 6f9710b..4d752bf 100644
--- a/src/math/axis.cc
+++ b/src/math/axis.cc
@@ -89,7 +89,9 @@ Axis const Axis::transpose()
// write an axis to a std::ostream
std::ostream &operator<<(std::ostream & os, Axis const & axis)
{
- os << axis.forward() << " " << axis.left() << " " << axis.up();
+ os << axis.forward() << " ";
+ os << axis.left() << " ";
+ os << axis.up();
return os;
}
@@ -102,4 +104,10 @@ std::istream &operator>>(std::istream & is, Axis & axis)
return is;
}
+// local-to-global coordinates
+Vector3f operator*(Axis const &axis, Vector3f const &vector)
+{
+ return (Vector3f(vector[0] * axis[0] + vector[1] * axis[1] + vector[2] * axis[2]));
+}
+
}
diff --git a/src/math/axis.h b/src/math/axis.h
index 7e81d9a..d011675 100644
--- a/src/math/axis.h
+++ b/src/math/axis.h
@@ -58,6 +58,9 @@ std::ostream &operator<<(std::ostream & os, Axis const & axis);
/// read an axis from a std::istream
std::istream &operator>>(std::istream & is, Axis & axis);
+/// local-to-global coordinates
+Vector3f operator*(Axis const &axis, Vector3f const &vector);
+
}
#endif // __INCLUDED_MATH_AXIS_H__
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 4b42596..5697cae 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -36,6 +36,7 @@ const float drawfxdistance = 32.0f;
math::Vector3f camera_target;
math::Vector3f camera_eye;
+math::Axis camera_axis;
float angle = 0;
@@ -181,27 +182,6 @@ void draw_model_evertex(core::Entity *entity)
}
}
-void draw_model_lights(core::Entity *entity)
-{
- core::Model *model = entity->model();
-
- if (model->model_light.size()) {
- glPointSize(10);
- gl::begin(gl::Points);
-
- for (std::list<core::Light *>::iterator lit = model->model_light.begin(); lit != model->model_light.end(); lit++) {
- if (!(*lit)->strobe() || (( core::application()->time() - floorf(core::application()->time()) ) < 0.5f)) {
- math::Vector3f location = (*lit)->location();
- gl::color((*lit)->color());
- gl::vertex(location);
- }
- }
-
- gl::end();
- glPointSize(1);
- }
-}
-
void draw_model_engines(core::EntityControlable *entity)
{
core::Model *model = entity->model();
@@ -364,7 +344,7 @@ void draw_pass_model_evertex()
}
}
-/* Draw model lights, engines */
+/* Draw model shields and engines */
void draw_pass_model_fx() {
for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
@@ -373,23 +353,68 @@ void draw_pass_model_fx() {
if (test_drawfx_distance(entity)) {
- gl::push();
- gl::translate(entity->location());
- // FIXME
- //gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
- gl::multmatrix(entity->axis());
-
- draw_model_lights(entity);
-
+
if (entity->type() == core::Entity::Controlable) {
+ gl::push();
+ gl::translate(entity->location());
+ gl::multmatrix(entity->axis());
+
draw_model_engines((core::EntityControlable *)entity);
draw_model_shield((core::EntityControlable *)entity);
+ gl::pop();
}
- gl::pop();
+
}
}
}
+/* draw model lights */
+
+void draw_pass_model_lights()
+{
+ //glPointSize(10);
+ glBindTexture(GL_TEXTURE_2D, render::textures[3]); // bitmaps/fx/flare01.tga
+ gl::enable(GL_TEXTURE_2D);
+
+ gl::begin(gl::Quads);
+
+ const float light_size = 0.0625;
+
+ for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
+ core::Entity *entity = (*it).second;
+
+ if ( test_drawfx_distance(entity) && (entity->model()->model_light.size())) {
+
+ for (std::list<core::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) {
+ if (!(*lit)->strobe() || (( core::application()->time() - floorf(core::application()->time()) ) < 0.5f)) {
+ math::Vector3f location = entity->location() + (entity->axis() * (*lit)->location());
+ float n = dotproduct(camera_axis.forward(), (camera_eye-location));
+
+ if (n < 0) {
+ math::Color color((*lit)->color());
+ color.a = fabs(-atanf(n) * 2 / M_PI);
+ gl::color(color);
+
+ glTexCoord2f(0,1);
+ gl::vertex(location + (camera_axis.up() - camera_axis.left()) * light_size);
+ glTexCoord2f(0,0);
+ gl::vertex(location + (camera_axis.up() + camera_axis.left()) * light_size);
+ glTexCoord2f(-1,0);
+ gl::vertex(location + (camera_axis.up() * -1 + camera_axis.left()) * light_size);
+ glTexCoord2f(-1,1);
+ gl::vertex(location + (camera_axis.up() * -1 - camera_axis.left()) * light_size);
+ }
+ }
+ }
+ }
+ }
+
+ gl::end();
+ gl::disable(GL_TEXTURE_2D);
+ //glPointSize(1);
+
+}
+
void draw_pass_model_radius()
{
if (!(r_radius && r_radius->value()))
@@ -485,7 +510,7 @@ void draw_local_axis()
}
/* ----- Main draw routine ----------------------------------------- */
-void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds)
+void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f const &target, float seconds)
{
Stats::clear();
@@ -497,6 +522,7 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds
camera_target.assign(target);
camera_eye.assign(eye);
+ camera_axis.assign(axis);
gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
gl::enable(GL_CULL_FACE); // enable culling
@@ -533,7 +559,10 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds
gl::disable(GL_LIGHTING);
gl::enable(GL_BLEND);
- draw_pass_model_fx(); // draw entity lights and engines
+ draw_pass_spacegrid(); // draw the blue spacegrid
+
+ draw_pass_model_fx(); // draw entity shield and engines
+ draw_pass_model_lights(); // draw entity lights
gl::enable(GL_LIGHTING);
gl::enable(GL_RESCALE_NORMAL);
@@ -547,11 +576,6 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds
gl::disable(GL_LIGHTING);
gl::disable(GL_COLOR_MATERIAL); // disable color tracking
gl::disable(GL_CULL_FACE); // disable culling
-
- // draw_local_axis();
-
- draw_pass_spacegrid(); // draw the blue spacegrid
-
gl::disable(GL_DEPTH_TEST); // disable depth buffer
// GL_BLEND must be enabled for the GUI
diff --git a/src/render/draw.h b/src/render/draw.h
index b423aad..65e15ee 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -13,7 +13,7 @@ namespace render
{
/// draw the world
-void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds);
+void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f const &target, float seconds);
class Stats {
public:
diff --git a/src/render/render.cc b/src/render/render.cc
index 7f79a85..6755e08 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -75,6 +75,11 @@ void init()
core::application()->shutdown();
}
+ if (!texture("bitmaps/fx/flare01.tga", 3)) {
+ con_error << "Essential file bitmaps/fx/flare01.tga missing" << std::endl;
+ core::application()->shutdown();
+ }
+
// size of the vertex array in megabytes
r_arraysize = core::Cvar::get("r_arraysize", 0.0f , core::Cvar::Archive);
r_arraysize->set_info("[int] size of the vertex array in Mb");