Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-04 01:17:44 +0000
committerStijn Buys <ingar@osirion.org>2008-02-04 01:17:44 +0000
commit09fb43f3d36847977ac202c10c5a11f34af03a43 (patch)
tree45f4537347e9f8b3195cea00356963e9879a08fa
parent840f9b8678f607aecc15d47bc77248c4ac8b8574 (diff)
astyle
-rw-r--r--osirion.kdevelop6
-rw-r--r--osirion.kdevelop.pcsbin273656 -> 278847 bytes
-rw-r--r--osirion.kdevses6
-rw-r--r--src/client/application.cc2
-rw-r--r--src/client/application.h12
-rw-r--r--src/client/view.cc98
-rw-r--r--src/core/applicationinterface.cc51
-rw-r--r--src/core/commandbuffer.cc26
-rw-r--r--src/core/func.cc11
-rw-r--r--src/core/gameinterface.cc2
-rw-r--r--src/filesystem/filesystem.cc10
-rw-r--r--src/filesystem/inifile.cc18
-rw-r--r--src/filesystem/path.cc9
-rw-r--r--src/math/color.cc50
-rw-r--r--src/math/color.h64
-rw-r--r--src/math/functions.cc35
-rw-r--r--src/math/functions.h7
-rw-r--r--src/math/mathlib.h4
-rw-r--r--src/math/vector3f.cc170
-rw-r--r--src/math/vector3f.h16
-rw-r--r--src/sys/consoleinterface.cc8
-rw-r--r--src/sys/consoleinterface.h6
-rw-r--r--src/sys/sys.h37
23 files changed, 354 insertions, 294 deletions
diff --git a/osirion.kdevelop b/osirion.kdevelop
index bc6bf04..58a8bfc 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/osirion</activetarget>
+ <activetarget>src/client/libclient.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
@@ -29,12 +29,12 @@
<terminal>true</terminal>
<directoryradio>executable</directoryradio>
<runarguments>
- <osirion></osirion>
+ <osirion/>
<osiriond/>
</runarguments>
<debugarguments>
<osiriond/>
- <osirion></osirion>
+ <osirion/>
</debugarguments>
<cwd>
<osiriond>/home/ingar/projects/osirion/osirion-work/debug/src/</osiriond>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index 8f468cc..3e0567c 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index ba26c45..e8415d1 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,11 +1,7 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="1" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/configure.in" >
- <View0 Encoding="" line="105" Type="Source" />
- </Doc0>
- </DocsAndViews>
+ <DocsAndViews NumberOfDocuments="0" />
<pluginList>
<kdevdebugger>
<breakpointList/>
diff --git a/src/client/application.cc b/src/client/application.cc
index b7505a1..7a88155 100644
--- a/src/client/application.cc
+++ b/src/client/application.cc
@@ -64,7 +64,7 @@ void Application::run()
// update the core chronometer
float seconds = ((float)(current - chrono)) / 1000.0f;
frame(seconds);
-
+
// update the video chronometers and draw
video.frame(seconds);
if (seconds > 0)
diff --git a/src/client/application.h b/src/client/application.h
index 62eccd6..150b24e 100644
--- a/src/client/application.h
+++ b/src/client/application.h
@@ -1,7 +1,7 @@
/*
client/application.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_CLIENT_APPLICATION_H__
@@ -9,10 +9,12 @@
#include "core/applicationinterface.h"
-namespace client {
+namespace client
+{
/// client Application implementation
-class Application : public core::ApplicationInterface {
+class Application : public core::ApplicationInterface
+{
public:
/// initialize the client Application
virtual void init();
@@ -25,7 +27,7 @@ public:
/// quit the client Application
virtual void quit(int status);
-
+
/// current fps
float current_fps;
};
diff --git a/src/client/view.cc b/src/client/view.cc
index 1dd0df6..811a7f7 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -1,7 +1,7 @@
-/*
+/*
view.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include "client/client.h"
@@ -27,17 +27,18 @@ StarDrawer *stardrawer = 0;
game::Ship *target = 0; // the view's target
-void View::init() {
+void View::init()
+{
// draw scene
if (!shipdrawer) {
stardrawer = new StarDrawer(&game.star);
- shipdrawer = new ShipDrawer(&game.ship);
+ shipdrawer = new ShipDrawer(&game.ship);
target = &game.ship;
}
-
+
}
-void View::shutdown()
+void View::shutdown()
{
delete stardrawer;
stardrawer = 0;
@@ -45,26 +46,27 @@ void View::shutdown()
shipdrawer = 0;
}
-void View::reset() {
- // shading model: Gouraud (smooth).
+void View::reset()
+{
+ // shading model: Gouraud (smooth).
gl::shademodel(GL_SMOOTH);
// culling
- gl::cullface( GL_BACK );
- gl::frontface(GL_CCW );
+ gl::cullface(GL_BACK);
+ gl::frontface(GL_CCW);
// alpha-blending
- gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl::disable(GL_BLEND);
-
+
// depth
gl::depthmask(GL_TRUE);
gl::disable(GL_DEPTH_TEST);
- gl::disable( GL_CULL_FACE );
-}
+ gl::disable(GL_CULL_FACE);
+}
-void View::draw_world(float elapsed)
+void View::draw_world(float elapsed)
{
// draw the world
gl::push();
@@ -75,7 +77,7 @@ void View::draw_world(float elapsed)
gl::pop();
gl::push();
- gl::translate(game.star.location - target->location);
+ gl::translate(game.star.location - target->location);
stardrawer->draw(elapsed);
gl::pop();
@@ -84,7 +86,7 @@ void View::draw_world(float elapsed)
void View::draw_background(float elapsed)
{
using namespace gl;
-
+
// galactic axis
begin(Lines);
color(0.9f, 0.5f, 0.0f);
@@ -106,9 +108,9 @@ void View::draw_background(float elapsed)
float dx = target->location.x - floorf(target->location.x);
float dz = target->location.z - floorf(target->location.z);
- color(0,0, 1.0f);
- begin(Lines);
- for (int i=-gridsize; i <= gridsize; i++) {
+ color(0,0, 1.0f);
+ begin(Lines);
+ for (int i=-gridsize; i <= gridsize; i++) {
color(0,0, 0, 0);
vertex(i-dx, y, -gridsize-dz);
color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
@@ -116,14 +118,14 @@ void View::draw_background(float elapsed)
vertex(i-dx, y, -dz);
color(0,0, 0, 0);
vertex(i-dx, y, gridsize-dz);
-
+
vertex(-gridsize-dx, y, i-dz);
color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
vertex(-dx, y, i-dz);
vertex(-dx, y, i-dz);
color(0,0, 0, 0);
vertex(gridsize-dx, y, i-dz);
- }
+ }
end();
}
@@ -132,12 +134,12 @@ void View::draw_loader()
gl::enable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, render::textures[0]); // bitmaps/loader.tga
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
-
+
gl::begin(gl::Quads);
-
+
glTexCoord2f(0.0f, 0.0f);
gl::vertex(0,0, 0);
-
+
glTexCoord2f(1.0f, 0.0f);
gl::vertex(video.width,0,0);
@@ -164,13 +166,13 @@ void View::draw_status()
// print the status in the upper left corner
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
std::stringstream status;
-
- int hours = (int) sys::time() / 3600;
- int minutes = (int) (sys::time() - 3600*hours) / 60;
- int seconds = (int) (sys::time() - 3600*hours - 60 *minutes);
- status << " clock " << setfill('0') << setw(2) << hours << ":"
- << setfill('0') << setw(2) << minutes << ":"
- << setfill('0') << setw(2) << seconds;
+
+ int hours = (int) sys::time() / 3600;
+ int minutes = (int)(sys::time() - 3600*hours) / 60;
+ int seconds = (int)(sys::time() - 3600*hours - 60 *minutes);
+ status << " clock " << setfill('0') << setw(2) << hours << ":"
+ << setfill('0') << setw(2) << minutes << ":"
+ << setfill('0') << setw(2) << seconds;
minutes = (int) floorf(core::time() / 60.0f);
seconds = (int) floorf(core::time() - (float) minutes* 60.0f);
@@ -188,16 +190,16 @@ void View::draw_status()
gl::disable(GL_TEXTURE_2D);
}
-void View::frame(float seconds)
+void View::frame(float seconds)
{
// Clear the color and depth buffers.
- gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
+ gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
if (core::connected()) {
// draw the game world
-
+
// Change to the projection matrix and set our viewing volume.
- gl::matrixmode( GL_PROJECTION );
+ gl::matrixmode(GL_PROJECTION);
gl::loadidentity();
const float frustumsize = 0.5f;
@@ -207,32 +209,32 @@ void View::frame(float seconds)
height = 1;
gl::frustum(x, x+width, y, y +height, 1.0f, 1024.0f);
- gl::matrixmode( GL_MODELVIEW );
+ gl::matrixmode(GL_MODELVIEW);
gl::loadidentity();
gl::rotate(90.0f, 0, 1.0, 0);
-
+
// Camera transformation
camera.draw(seconds);
gl::enable(GL_DEPTH_TEST); // enable depth buffer writing
gl::enable(GL_CULL_FACE); // enable culling
-
+
draw_world(seconds); // draw the world
- gl::disable(GL_CULL_FACE); // disable culling
+ gl::disable(GL_CULL_FACE); // disable culling
gl::enable(GL_BLEND); // enable alpha blending
- draw_background(seconds); // draw the spacegrid
+ draw_background(seconds); // draw the spacegrid
gl::disable(GL_DEPTH_TEST); // disable depth buffer writing
}
// switch to ortographic projection to draw the GUI
- gl::matrixmode( GL_PROJECTION );
- gl::loadidentity();
+ gl::matrixmode(GL_PROJECTION);
+ gl::loadidentity();
glOrtho(0, video.width, video.height, 0, -1000.0f, 1000.0f);
-
- gl::matrixmode( GL_MODELVIEW );
+
+ gl::matrixmode(GL_MODELVIEW);
gl::loadidentity();
if (!core::connected()) {
@@ -240,7 +242,7 @@ void View::frame(float seconds)
draw_loader();
gl::enable(GL_BLEND); // enable alpha blending
}
-
+
// draw the console
console.draw();
diff --git a/src/core/applicationinterface.cc b/src/core/applicationinterface.cc
index 63e1dea..561bf94 100644
--- a/src/core/applicationinterface.cc
+++ b/src/core/applicationinterface.cc
@@ -12,41 +12,47 @@
#include <errno.h>
#include <signal.h>
-namespace core {
+namespace core
+{
// --------------- function repository ------------------------------
-extern "C" void func_print(std::stringstream &args) {
+extern "C" void func_print(std::stringstream &args)
+{
char text[MAXCMDSIZE];
// FIXME leading space
- if(args.getline(text, MAXCMDSIZE))
+ if (args.getline(text, MAXCMDSIZE))
con_print << text << std::endl;
}
-extern "C" void func_help(std::stringstream &args) {
+extern "C" void func_help(std::stringstream &args)
+{
con_print << "This is the help function" << std::endl;
}
-extern "C" void func_quit(std::stringstream &args) {
- if(ApplicationInterface::instance()) {
+extern "C" void func_quit(std::stringstream &args)
+{
+ if (ApplicationInterface::instance()) {
ApplicationInterface::instance()->shutdown();
ApplicationInterface::instance()->quit(0);
}
}
-extern "C" void func_connect(std::stringstream &args) {
- if(ApplicationInterface::instance())
+extern "C" void func_connect(std::stringstream &args)
+{
+ if (ApplicationInterface::instance())
ApplicationInterface::instance()->connect();
}
-extern "C" void func_disconnect(std::stringstream &args) {
- if(ApplicationInterface::instance())
+extern "C" void func_disconnect(std::stringstream &args)
+{
+ if (ApplicationInterface::instance())
ApplicationInterface::instance()->disconnect();
}
// --------------- signal_handler -----------------------------------
extern "C" void signal_handler(int signum)
{
- switch(signum){
+ switch (signum) {
case SIGHUP:
case SIGINT:
case SIGQUIT:
@@ -71,13 +77,14 @@ extern "C" void signal_handler(int signum)
ApplicationInterface *ApplicationInterface::applicationinterface_instance = 0;
-ApplicationInterface::ApplicationInterface() {
+ApplicationInterface::ApplicationInterface()
+{
if (applicationinterface_instance) {
std::cerr << "multiple singleton instances: core::ApplicationInterface" << std::endl;
sys::quit(2);
}
applicationinterface_instance = this;
-
+
sys::signal(SIGHUP, signal_handler);
sys::signal(SIGINT, signal_handler);
sys::signal(SIGQUIT, signal_handler);
@@ -94,7 +101,7 @@ ApplicationInterface *ApplicationInterface::instance()
return applicationinterface_instance;
}
-void ApplicationInterface::init()
+void ApplicationInterface::init()
{
con_print << "Initializing core..." << std::endl;
con_debug << "Debug messages enabled" << std::endl;
@@ -110,10 +117,10 @@ void ApplicationInterface::init()
func_register("connect", func_connect);
func_register("disconnect", func_disconnect);
- if (game())
- game()->connected = false;
- else
- con_warn << "No game module loaded!" << std::endl;
+ if (game())
+ game()->connected = false;
+ else
+ con_warn << "No game module loaded!" << std::endl;
current_time = 0;
}
@@ -124,8 +131,8 @@ void ApplicationInterface::shutdown()
if (game())
if (game()->connected)
disconnect();
- else
- con_warn << "No game module loaded!" << std::endl;
+ else
+ con_warn << "No game module loaded!" << std::endl;
filesystem::shutdown();
}
@@ -133,7 +140,7 @@ void ApplicationInterface::shutdown()
void ApplicationInterface::quit(int status)
{
sys::quit(status);
-}
+}
void ApplicationInterface::connect()
{
@@ -141,7 +148,7 @@ void ApplicationInterface::connect()
con_warn << "No game module loaded!" << std::endl;
return;
}
-
+
if (game()->connected) {
con_warn << "Connected. Disconnect first." << std::endl;
}
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index fbeba7b..292013b 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -1,7 +1,7 @@
/*
core/commandbuffer.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#include "core/commandbuffer.h"
@@ -11,18 +11,20 @@
#include <string>
#include <sstream>
-namespace core {
+namespace core
+{
std::stringstream cmd(std::stringstream::in | std::stringstream::out);
namespace commandbuffer {
-void exec(const char *text) {
+void exec(const char *text)
+{
std::stringstream cmdstream(text);
std::string cmdname;
cmdstream >> cmdname;
-
+
Func f = func_find(cmdname);
if (f) {
@@ -33,24 +35,26 @@ void exec(const char *text) {
con_print << "unknown command '" << cmdname << "'" << std::endl;
}
-void execute() {
+void execute()
+{
if (core::cmd.eof())
return;
char line[MAXCMDSIZE];
- while(core::cmd.getline(line, MAXCMDSIZE-1)) {
+ while (core::cmd.getline(line, MAXCMDSIZE-1)) {
exec(line);
}
cmd.clear();
}
-void clear() {
+void clear()
+{
char line[MAXCMDSIZE];
- while(core::cmd.getline(line, MAXCMDSIZE-1));
+ while (core::cmd.getline(line, MAXCMDSIZE-1));
}
-}
+} // namespace commandbuffer
-}
+} // namespace core
diff --git a/src/core/func.cc b/src/core/func.cc
index c4f14db..b89e556 100644
--- a/src/core/func.cc
+++ b/src/core/func.cc
@@ -1,13 +1,14 @@
/*
core/func.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#include "core/func.h"
#include <map>
-namespace core {
+namespace core
+{
std::map<std::string, Func> functionmap;
@@ -15,7 +16,7 @@ void func_register(const char * functionname, Func functionptr)
{
functionmap[std::string(functionname)] = functionptr;
}
-
+
void func_unregister(std:: string functionname)
{
functionmap.erase(std::string(functionname));
@@ -26,4 +27,4 @@ Func func_find(std::string functionname)
return functionmap[functionname];
}
-}
+} // namespace core
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 86e8556..639a522 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -34,4 +34,4 @@ GameInterface *GameInterface::instance()
return gameinterface_instance;
}
-}
+} // namespace core
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index 5d3ed40..da80ea5 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -13,13 +13,14 @@ std::string filesystem::homedir = "";
std::string filesystem::basedir = "";
std::string filesystem::moddir = "";
-void filesystem::init() {
+void filesystem::init()
+{
con_print << "Initializing filesystem..." << std::endl;
// FIXME datadir should by set by ./configure and read from config.h
// initialize game data locations
- datadir = "./data/";
+ datadir = "./data/";
basedir = "base/";
moddir = "";
@@ -28,11 +29,12 @@ void filesystem::init() {
homedir = homedir + "/.osirion/";
Path::create(homedir);
Path::create(homedir+basedir);
- if (moddir.size() && !Path::exists(homedir+moddir))
+ if (moddir.size() && !Path::exists(homedir+moddir))
Path::create(homedir+moddir);
}
-void filesystem::shutdown() {
+void filesystem::shutdown()
+{
con_print << "Shutting down filesystem..." << std::endl;
}
diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc
index 57778b3..f04d116 100644
--- a/src/filesystem/inifile.cc
+++ b/src/filesystem/inifile.cc
@@ -7,13 +7,15 @@
// project headers
#include "filesystem/inifile.h"
-namespace filesystem {
+namespace filesystem
+{
IniFile::IniFile() {}
IniFile::~IniFile() {}
-void IniFile::open(const char * filename, std::ios_base::openmode mode) {
+void IniFile::open(const char * filename, std::ios_base::openmode mode)
+{
last_read_was_section = false;
last_read_was_key = false;
key_current = "";
@@ -25,15 +27,18 @@ void IniFile::open(const char * filename, std::ios_base::openmode mode) {
}
-bool IniFile::got_section() const {
+bool IniFile::got_section() const
+{
return last_read_was_section;
}
-bool IniFile::got_section(const char * sectionlabel) const {
+bool IniFile::got_section(const char * sectionlabel) const
+{
return (last_read_was_section && section_current == sectionlabel);
}
-IniFile & IniFile::getline() {
+IniFile & IniFile::getline()
+{
char line[1024];
last_read_was_section = false;
@@ -79,7 +84,8 @@ IniFile & IniFile::getline() {
return (*this);
}
-bool IniFile::got_key_string(char * const keylabel, std::string & valuestring) {
+bool IniFile::got_key_string(char * const keylabel, std::string & valuestring)
+{
//condebug << "IniFile got_value_string " << keylabel << " " << last_read_was_key << std::endl;
if (last_read_was_key && key_current == keylabel) {
valuestring.assign(value_current);
diff --git a/src/filesystem/path.cc b/src/filesystem/path.cc
index c090791..44423b0 100644
--- a/src/filesystem/path.cc
+++ b/src/filesystem/path.cc
@@ -8,9 +8,11 @@
#include "filesystem/path.h"
#include "sys/sys.h"
-namespace filesystem {
+namespace filesystem
+{
-void Path::create(std::string path) {
+void Path::create(std::string path)
+{
std::string tmp(path);
if (tmp[tmp.size()-1] == '/')
tmp = tmp.substr(0, tmp.size() - 1);
@@ -21,7 +23,8 @@ void Path::create(std::string path) {
con_debug << "directory created " << tmp << std::endl;
}
-bool Path::exists(std::string path) {
+bool Path::exists(std::string path)
+{
return false;
}
diff --git a/src/math/color.cc b/src/math/color.cc
index e41a5aa..b0c3f65 100644
--- a/src/math/color.cc
+++ b/src/math/color.cc
@@ -1,36 +1,42 @@
/*
math/color.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
// project headers
#include "math/color.h"
-namespace math {
+namespace math
+{
-Color::Color() {
+Color::Color()
+{
_r = _g = _b = 0.0f;
_a = 1.0f;
}
-Color::Color(const float red, const float green , const float blue , const float alpha) {
+Color::Color(const float red, const float green , const float blue , const float alpha)
+{
_r = red;
_g = green;
_b = blue;
_a = alpha;
}
-Color::Color(const float grey, const float alpha) {
+Color::Color(const float grey, const float alpha)
+{
_r = _g = _b = grey;
_a = alpha;
}
-Color::Color(const Color &other) {
+Color::Color(const Color &other)
+{
this->operator=(other);
}
-const Color & Color::operator=(const Color &other) {
+const Color & Color::operator=(const Color &other)
+{
this->_r = other._r;
this->_g = other._g;
this->_b = other._b;
@@ -38,45 +44,53 @@ const Color & Color::operator=(const Color &other) {
return (*this);
}
-void Color::normalize() {
+void Color::normalize()
+{
float tmp = _r;
if (_g > tmp)
tmp = _g;
- if ( _b > tmp)
+ if (_b > tmp)
tmp = _b;
if (tmp > 1) {
_r /= tmp;
_g /= tmp;
_b /= tmp;
- }
+ }
}
-float Color::red() const {
+float Color::red() const
+{
return _r;
}
-float Color::green() const {
+float Color::green() const
+{
return _g;
}
-float Color::blue() const {
+float Color::blue() const
+{
return _b;
}
-float Color::alpha() const {
+float Color::alpha() const
+{
return _a;
}
-Color Color::operator*(float scalar) const {
+Color Color::operator*(float scalar) const
+{
return Color(red()*scalar, green()*scalar, blue()*scalar, alpha());
}
-Color operator*(float scalar, const Color& color) {
+Color operator*(float scalar, const Color& color)
+{
return color * scalar;
}
-std::ostream &operator<<(std::ostream &os, const Color &c) {
+std::ostream &operator<<(std::ostream &os, const Color &c)
+{
os << c.red() << " " << c.green() << " " << c.blue() << " " << c.alpha();
return os;
}
diff --git a/src/math/color.h b/src/math/color.h
index 2c69b9b..33efcfc 100644
--- a/src/math/color.h
+++ b/src/math/color.h
@@ -1,44 +1,46 @@
/*
common/color.h
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MATH_COLOR_H__
#define __INCLUDED_MATH_COLOR_H__
-#include <iostream>
+#include <iostream>
-namespace math {
+namespace math
+{
/// a class representing an RGBA color value
-class Color {
- public:
- Color();
- Color(const float, float const, const float, const float=1.0f);
- Color(const float, const float=1.0f);
- Color(const Color &);
-
- float red() const;
- float green() const;
- float blue() const;
- float alpha() const;
-
- const Color &operator=(const Color &);
-
- Color operator*(const float scalar) const;
-
- // Some default colors
- static const Color Black() { return Color(0.0f); };
- static const Color White() { return Color(1.0f); };
- static const Color Red() { return Color(1.0f,0.0f,0.0f); };
- static const Color Green() { return Color(0.0f,1.0f,0.0f); };
- static const Color Blue() { return Color(0.0f, 0.0f, 1.0f); };
- static const Color Yellow() { return Color(1.0f, 1.0f, 0.0f); };
-
- private:
- void normalize();
- float _r, _g, _b, _a;
+class Color
+{
+public:
+ Color();
+ Color(const float, float const, const float, const float=1.0f);
+ Color(const float, const float=1.0f);
+ Color(const Color &);
+
+ float red() const;
+ float green() const;
+ float blue() const;
+ float alpha() const;
+
+ const Color &operator=(const Color &);
+
+ Color operator*(const float scalar) const;
+
+ // Some default colors
+ static const Color Black() { return Color(0.0f); };
+ static const Color White() { return Color(1.0f); };
+ static const Color Red() { return Color(1.0f,0.0f,0.0f); };
+ static const Color Green() { return Color(0.0f,1.0f,0.0f); };
+ static const Color Blue() { return Color(0.0f, 0.0f, 1.0f); };
+ static const Color Yellow() { return Color(1.0f, 1.0f, 0.0f); };
+
+private:
+ void normalize();
+ float _r, _g, _b, _a;
};
std::ostream &operator<<(std::ostream &os, const Color &c);
diff --git a/src/math/functions.cc b/src/math/functions.cc
index 0e394c1..53ce41e 100644
--- a/src/math/functions.cc
+++ b/src/math/functions.cc
@@ -1,39 +1,47 @@
/*
common/functions.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
// project headers
#include "math/functions.h"
-namespace math {
+namespace math
+{
-float min(float a, float b) {
+float min(float a, float b)
+{
return (a < b ? a : b);
}
-float max(float a, float b) {
+float max(float a, float b)
+{
return (a > b ? a : b);
}
-int min(int a, int b) {
+int min(int a, int b)
+{
return (a < b ? a : b);
}
-int max(int a, int b) {
+int max(int a, int b)
+{
return (a > b ? a : b);
}
-float randomf(const float max) {
+float randomf(const float max)
+{
return ((float) rand() / (float) RAND_MAX) * max;
}
-unsigned randomi(const unsigned int max) {
+unsigned randomi(const unsigned int max)
+{
return ((unsigned int)(rand() % max));
}
-float degrees180f(float angle) {
+float degrees180f(float angle)
+{
float r = angle;
while (r <= -180.0f)
r += 360.0f;
@@ -42,7 +50,8 @@ float degrees180f(float angle) {
return r;
}
-float degrees360f(float angle) {
+float degrees360f(float angle)
+{
float r = angle;
while (r < 0.0f)
r += 360.0f;
@@ -53,9 +62,9 @@ float degrees360f(float angle) {
float sgnf(float value)
{
- if (value < 0 )
+ if (value < 0)
return -1;
- else if (value == 0 )
+ else if (value == 0)
return 0;
return 1;
diff --git a/src/math/functions.h b/src/math/functions.h
index 767af2d..df86124 100644
--- a/src/math/functions.h
+++ b/src/math/functions.h
@@ -1,7 +1,7 @@
/*
math/functions.h
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MATH_FUNCTIONS_H__
@@ -11,7 +11,8 @@
#include <cstdlib>
#include <cmath>
-namespace math {
+namespace math
+{
/// return the smallest of two float values
float min(float a, float b);
diff --git a/src/math/mathlib.h b/src/math/mathlib.h
index 2e1c245..ca5b7f4 100644
--- a/src/math/mathlib.h
+++ b/src/math/mathlib.h
@@ -1,7 +1,7 @@
/*
math/math.h
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MATH_H__
diff --git a/src/math/vector3f.cc b/src/math/vector3f.cc
index da3ff12..277795b 100644
--- a/src/math/vector3f.cc
+++ b/src/math/vector3f.cc
@@ -1,7 +1,7 @@
/*
common/vector3f.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
// project headers
@@ -10,151 +10,155 @@
// C++ headers
#include <cmath>
-namespace math {
+namespace math
+{
-Vector3f::Vector3f() :
- x(coord[0]), y(coord[1]), z(coord[2])
+Vector3f::Vector3f() :
+ x(coord[0]), y(coord[1]), z(coord[2])
{
- for (int i=0; i < 3; i++)
- coord[i] = 0;
+ for (int i=0; i < 3; i++)
+ coord[i] = 0;
}
-
-Vector3f::Vector3f(const Vector3f &other) :
- x(coord[0]), y(coord[1]), z(coord[2])
+Vector3f::Vector3f(const Vector3f &other) :
+ x(coord[0]), y(coord[1]), z(coord[2])
{
for (int i=0; i < 3; i++)
coord[i] = other.coord[i];
}
-Vector3f::Vector3f(const float xv, const float yv, const float zv) :
- x(coord[0]), y(coord[1]), z(coord[2])
+Vector3f::Vector3f(const float xv, const float yv, const float zv) :
+ x(coord[0]), y(coord[1]), z(coord[2])
{
coord[0] = xv;
coord[1] = yv;
coord[2] = zv;
}
-Vector3f::~Vector3f()
+Vector3f::~Vector3f()
{
}
-
-Vector3f & Vector3f::operator=(const Vector3f & other)
+Vector3f & Vector3f::operator=(const Vector3f & other)
{
for (int i=0; i < 3; i++)
coord[i] = other.coord[i];
return (*this);
}
-
-Vector3f & Vector3f::operator*=(const float scalar)
+Vector3f & Vector3f::operator*=(const float scalar)
{
- for (int i=0; i < 3; i++)
- coord[i] *= scalar;
- return (*this);
+ for (int i=0; i < 3; i++)
+ coord[i] *= scalar;
+ return (*this);
}
-
-Vector3f & Vector3f::operator/=(const float scalar) {
- for (int i=0; i < 3; i++)
- coord[i] /= scalar;
- return (*this);
+Vector3f & Vector3f::operator/=(const float scalar)
+{
+ for (int i=0; i < 3; i++)
+ coord[i] /= scalar;
+ return (*this);
}
-
-Vector3f &Vector3f::operator-=(const Vector3f & other) {
- for (int i=0; i < 3; i++)
- coord[i] -= other[i];
- return (*this);
+Vector3f &Vector3f::operator-=(const Vector3f & other)
+{
+ for (int i=0; i < 3; i++)
+ coord[i] -= other[i];
+ return (*this);
}
-
-Vector3f &Vector3f::operator+=(const Vector3f &other) {
- for (int i=0; i < 3; i++)
- coord[i] += other[i];
- return (*this);
+Vector3f &Vector3f::operator+=(const Vector3f &other)
+{
+ for (int i=0; i < 3; i++)
+ coord[i] += other[i];
+ return (*this);
}
-
-Vector3f Vector3f::operator*(const float scalar) const {
- Vector3f r(*this);
- for (int i=0; i < 3; i++)
- r.coord[i] *= scalar;
- return (r);
- }
-
-
-Vector3f Vector3f::operator/(const float scalar) const {
- Vector3f r(*this);
- for (int i=0; i < 3; i++)
- r.coord[i] /= scalar;
- return (r);
+Vector3f Vector3f::operator*(const float scalar) const
+{
+ Vector3f r(*this);
+ for (int i=0; i < 3; i++)
+ r.coord[i] *= scalar;
+ return (r);
}
-
-Vector3f Vector3f::operator-(const Vector3f& other) const {
- Vector3f r(*this);
- for (int i=0; i < 3; i++)
- r.coord[i] -= other.coord[i];
- return (r);
+Vector3f Vector3f::operator/(const float scalar) const
+{
+ Vector3f r(*this);
+ for (int i=0; i < 3; i++)
+ r.coord[i] /= scalar;
+ return (r);
}
-
-Vector3f Vector3f::operator+(const Vector3f& other) const {
- Vector3f r(*this);
- for (int i=0; i < 3; i++)
- r.coord[i] += other.coord[i];
- return (r);
+Vector3f Vector3f::operator-(const Vector3f& other) const
+{
+ Vector3f r(*this);
+ for (int i=0; i < 3; i++)
+ r.coord[i] -= other.coord[i];
+ return (r);
}
-
-float Vector3f::operator*(const Vector3f& other) const {
- float r = 0;
- for (int i=0; i < 3; i++)
- r += coord[i] * other.coord[i];
- return (r);
+Vector3f Vector3f::operator+(const Vector3f& other) const
+{
+ Vector3f r(*this);
+ for (int i=0; i < 3; i++)
+ r.coord[i] += other.coord[i];
+ return (r);
}
+float Vector3f::operator*(const Vector3f& other) const
+{
+ float r = 0;
+ for (int i=0; i < 3; i++)
+ r += coord[i] * other.coord[i];
+ return (r);
+}
-bool Vector3f::operator==(const Vector3f& other) const {
+bool Vector3f::operator==(const Vector3f& other) const
+{
for (int i=0; i < 3; i++)
if (coord[i] != other.coord[i])
return (false);
return (true);
}
-float Vector3f::lengthsquared() const {
- double r = 0;
- for (int i=0; i < 3; i++)
- r += coord[i]*coord[i];
- return ((float) r);
+float Vector3f::lengthsquared() const
+{
+ double r = 0;
+ for (int i=0; i < 3; i++)
+ r += coord[i]*coord[i];
+ return ((float) r);
}
-float Vector3f::length() const {
- double r = 0;
- for (int i=0; i < 3; i++)
- r += coord[i]*coord[i];
+float Vector3f::length() const
+{
+ double r = 0;
+ for (int i=0; i < 3; i++)
+ r += coord[i]*coord[i];
- return ((float) sqrt(r));
+ return ((float) sqrt(r));
}
-void Vector3f::normalize() {
- (*this) /= this->length();
+void Vector3f::normalize()
+{
+ (*this) /= this->length();
}
-std::ostream &operator<<(std::ostream & os, const Vector3f & vector) {
+std::ostream &operator<<(std::ostream & os, const Vector3f & vector)
+{
os << vector[0] << " " << vector[1] << " " << vector[2];
return os;
}
-std::istream &operator>>(std::istream & is, Vector3f & vector) {
+std::istream &operator>>(std::istream & is, Vector3f & vector)
+{
for (int i=0; i < 3; i++)
is >> vector[i];
return is;
}
-Vector3f operator*(float scalar, const Vector3f& vector) {
+Vector3f operator*(float scalar, const Vector3f& vector)
+{
return vector * scalar;
}
diff --git a/src/math/vector3f.h b/src/math/vector3f.h
index 8bc62ff..cc318b0 100644
--- a/src/math/vector3f.h
+++ b/src/math/vector3f.h
@@ -1,7 +1,7 @@
/*
math/vector3f.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MATH_VECTOR3F_H__
@@ -13,13 +13,15 @@
// C++ headers
#include <iostream>
-namespace math {
+namespace math
+{
/// a point or vector in 3D-space
/** An instance of this class represents a point in 3D-space or a 3D-vector
* and forms the basic building block for all spatial calculations.
*/
-class Vector3f {
+class Vector3f
+{
public:
/// Default constructor, creates a Vector3f (0,0,0)
@@ -96,14 +98,14 @@ public:
inline float operator[](const unsigned int index) const {
return coord[index];
}
-
+
float &x;
float &y;
float &z;
-
+
/// Return the cartesian length of this vector
float length() const;
-
+
/// Return the cartesian length squared (to speed up calculations)
float lengthsquared() const;
diff --git a/src/sys/consoleinterface.cc b/src/sys/consoleinterface.cc
index 45df367..5740807 100644
--- a/src/sys/consoleinterface.cc
+++ b/src/sys/consoleinterface.cc
@@ -10,11 +10,13 @@
#include <stdlib.h>
-namespace sys {
+namespace sys
+{
ConsoleInterface *ConsoleInterface::consoleinterface_instance = 0;
-ConsoleInterface::ConsoleInterface() {
+ConsoleInterface::ConsoleInterface()
+{
if (consoleinterface_instance) {
std::cerr << "multiple singleton instances: sys::ConsoleInterface" << std::endl;
sys::quit(2);
@@ -27,7 +29,7 @@ ConsoleInterface::~ConsoleInterface()
consoleinterface_instance = 0;
}
-ConsoleInterface *ConsoleInterface::instance()
+ConsoleInterface *ConsoleInterface::instance()
{
return consoleinterface_instance;
}
diff --git a/src/sys/consoleinterface.h b/src/sys/consoleinterface.h
index 6540d95..0215d55 100644
--- a/src/sys/consoleinterface.h
+++ b/src/sys/consoleinterface.h
@@ -27,10 +27,12 @@
#define con_debug if (0) *(std::ostream*)(0)
#endif
-namespace sys {
+namespace sys
+{
/// interface for the client and server Console classes
-class ConsoleInterface {
+class ConsoleInterface
+{
public:
/// default constructor
ConsoleInterface();
diff --git a/src/sys/sys.h b/src/sys/sys.h
index dec5ab9..4769832 100644
--- a/src/sys/sys.h
+++ b/src/sys/sys.h
@@ -13,25 +13,26 @@
#define MAXCMDSIZE 1024
/// contains operating system dependent functions
-/** sys is a core subsystem
+/** sys is a core subsystem
*/
-namespace sys {
- typedef void (* signalfunc)(int signum);
-
- /// create a directory
- extern bool mkdir(const char *path);
- /// intercept OS signals
- extern void signal(int signum, signalfunc handler);
- /// quit
- /** @param status return value
- */
- extern void quit(int status);
-
- /// suspend process for a number of seconds
- extern void sleep(float seconds);
-
- /// return the current system time of day, in seconds after midnight
- extern unsigned long time();
+namespace sys
+{
+typedef void (* signalfunc)(int signum);
+
+/// create a directory
+extern bool mkdir(const char *path);
+/// intercept OS signals
+extern void signal(int signum, signalfunc handler);
+/// quit
+/** @param status return value
+ */
+extern void quit(int status);
+
+/// suspend process for a number of seconds
+extern void sleep(float seconds);
+
+/// return the current system time of day, in seconds after midnight
+extern unsigned long time();
}