switch to horde3d
This commit is contained in:
parent
dbed4abb0b
commit
08ac71b995
@ -121,9 +121,6 @@ elseif (WIN32)
|
|||||||
#set (log4cplus_postfix "${log4cplus_postfix}S")
|
#set (log4cplus_postfix "${log4cplus_postfix}S")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
message (STATUS "Headers: ${log4cplus_headers}")
|
|
||||||
message (STATUS "Sources: ${log4cplus_sources}")
|
|
||||||
|
|
||||||
include_directories ("include")
|
include_directories ("include")
|
||||||
set (log4cplus_all_sources ${log4cplus_sources} ${log4cplus_headers})
|
set (log4cplus_all_sources ${log4cplus_sources} ${log4cplus_headers})
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
include_directories (${GREMLIN_SOURCE_DIR}/src/common)
|
include_directories (${GREMLIN_SOURCE_DIR}/src/common)
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/libs/horde3d-1.0.0-beta5/Include)
|
||||||
|
|
||||||
# define executable
|
# define executable
|
||||||
add_executable( gremlin
|
add_executable( gremlin
|
||||||
@ -6,14 +7,10 @@ add_executable( gremlin
|
|||||||
Explosion
|
Explosion
|
||||||
main
|
main
|
||||||
oglfont
|
oglfont
|
||||||
)
|
Window
|
||||||
|
Renderer
|
||||||
add_dependencies( gremlin
|
|
||||||
common
|
|
||||||
glfw
|
|
||||||
spark
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(gremlin
|
target_link_libraries(gremlin
|
||||||
common enet glfw spark log4cplus ${PLATFORM_LIBRARIES} ${OPENGL_LIBRARIES}
|
common enet glfw spark horde3d log4cplus ${PLATFORM_LIBRARIES} ${OPENGL_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
/*
|
|
||||||
* Client.cpp
|
|
||||||
*
|
|
||||||
* Created on: 14.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "Explosion.h"
|
#include "Explosion.h"
|
||||||
#include "Time.h"
|
#include "Time.h"
|
||||||
|
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
#include "Horde3D.h"
|
||||||
|
|
||||||
#include <GL/glfw.h>
|
#include <GL/glfw.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -19,110 +14,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
GLUquadricObj *quadratic;
|
namespace gln {
|
||||||
|
|
||||||
Explosion explosion;
|
Explosion explosion;
|
||||||
|
|
||||||
void setup_light() {
|
|
||||||
GLfloat LightAmbient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
|
||||||
GLfloat LightDiffuse[] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
|
||||||
GLfloat LightPosition[] = { 1.0f, 1.0f, 1.0f, 0.0f };
|
|
||||||
|
|
||||||
// setup directional light
|
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
|
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
|
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
|
|
||||||
glEnable(GL_LIGHT0);
|
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup_opengl() {
|
|
||||||
|
|
||||||
// Open OpenGL window
|
|
||||||
if (!glfwOpenWindow(640, 480, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) {
|
|
||||||
fprintf(stderr, "Failed to open GLFW window\n");
|
|
||||||
glfwTerminate();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
//glfwDisable(GLFW_MOUSE_CURSOR);
|
|
||||||
glfwSetWindowTitle("Gremlin Lan Party Game");
|
|
||||||
// Enable sticky keys
|
|
||||||
glfwEnable(GLFW_STICKY_KEYS);
|
|
||||||
|
|
||||||
// general settings
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
|
|
||||||
// setup depth buffer
|
|
||||||
glClearDepth(1.0f);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
|
|
||||||
// Enable vertical sync (on cards that support it)
|
|
||||||
glfwSwapInterval(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_team(Team *team) {
|
|
||||||
size_t i = 0;
|
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, team->color);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslated(team->x, team->y, team->z);
|
|
||||||
gluSphere(quadratic, 50.f, 32, 32);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
GLuint wallTex = 0;
|
|
||||||
void Client::drawPlayer(player_t *player) {
|
|
||||||
if (player->status == 0)
|
|
||||||
return;
|
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, player->team->color);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glMultMatrixf(player->m);
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
glVertexPointer(3, GL_FLOAT, game.shipMesh->vertex_size,
|
|
||||||
game.shipMesh->vertices);
|
|
||||||
glTexCoordPointer(2, GL_FLOAT, game.shipMesh->vertex_size,
|
|
||||||
game.shipMesh->vertices + 3);
|
|
||||||
glNormalPointer(GL_FLOAT, game.shipMesh->vertex_size,
|
|
||||||
game.shipMesh->vertices + 5);
|
|
||||||
for (size_t i = 0; i < game.shipMesh->object_count; i++) {
|
|
||||||
glDrawElements(GL_TRIANGLES, game.shipMesh->objects[i].face_count * 3,
|
|
||||||
GL_UNSIGNED_SHORT,
|
|
||||||
&game.shipMesh->faces[game.shipMesh->objects[i].face_index]);
|
|
||||||
}
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_bomb(bomb_t *bomb) {
|
|
||||||
if (bomb->status != 1)
|
|
||||||
return;
|
|
||||||
GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslated(bomb->x, bomb->y, bomb->z);
|
|
||||||
gluSphere(quadratic, 0.5f, 4, 4);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_point(point_t *point) {
|
|
||||||
if (point->status == 0)
|
|
||||||
return;
|
|
||||||
GLfloat red[] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslated(point->x, point->y, point->z);
|
|
||||||
gluSphere(quadratic, 3.f, 12, 12);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup_explosion() {
|
void setup_explosion() {
|
||||||
|
|
||||||
// Loads particle texture
|
// Loads particle texture
|
||||||
@ -169,155 +63,6 @@ void setup_explosion() {
|
|||||||
textures[4]);
|
textures[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::drawLevel() {
|
|
||||||
|
|
||||||
if (wallTex == 0) {
|
|
||||||
glGenTextures(1, &wallTex);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, wallTex);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
|
||||||
GL_LINEAR_MIPMAP_LINEAR);
|
|
||||||
glfwLoadTexture2D("data/wall.tga", GLFW_BUILD_MIPMAPS_BIT);
|
|
||||||
} else {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, wallTex);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLfloat red[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
|
||||||
|
|
||||||
// Enable/Disable features
|
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
//glDisable( GL_DEPTH_TEST);
|
|
||||||
// glEnable( GL_LIGHTING);
|
|
||||||
// glDisable( GL_BLEND);
|
|
||||||
glColor4f(1, 1, 1, 1);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
#if 0
|
|
||||||
glTranslated(2000.0, 0.0, 0.0);
|
|
||||||
//glScaled(5000.0f, 5000.0f, 5000.0f);
|
|
||||||
float s = 3000.0f, t = 10.0f;
|
|
||||||
// Just in case we set all vertices to white.
|
|
||||||
|
|
||||||
// Render the front quad
|
|
||||||
glBegin( GL_QUADS);
|
|
||||||
glTexCoord2f(0, t);
|
|
||||||
glNormal3f(0.0, 0.0, 1.0);
|
|
||||||
glVertex3f(-s, s, -s);
|
|
||||||
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glNormal3f(0.0, 0.0, 1.0);
|
|
||||||
glVertex3f(-s, -s, -s);
|
|
||||||
|
|
||||||
glTexCoord2f(t, 0);
|
|
||||||
glNormal3f(0.0, 0.0, 1.0);
|
|
||||||
glVertex3f(s, -s, -s);
|
|
||||||
|
|
||||||
glTexCoord2f(t, t);
|
|
||||||
glNormal3f(0.0, 0.0, 1.0);
|
|
||||||
glVertex3f(s, s, -s);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Render the left quad
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex3f(s, -s, s);
|
|
||||||
|
|
||||||
glTexCoord2f(0, t);
|
|
||||||
glVertex3f(s, s, s);
|
|
||||||
|
|
||||||
glTexCoord2f(t, t);
|
|
||||||
glVertex3f(s, s, -s);
|
|
||||||
|
|
||||||
glTexCoord2f(t, 0);
|
|
||||||
glVertex3f(s, -s, -s);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Render the back quad
|
|
||||||
// glBindTexture(GL_TEXTURE_2D, _skybox[2]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex3f(-s, -s, s);
|
|
||||||
glTexCoord2f(0, t);
|
|
||||||
glVertex3f(-s, s, s);
|
|
||||||
glTexCoord2f(t, t);
|
|
||||||
glVertex3f(s, s, s);
|
|
||||||
glTexCoord2f(t, 0);
|
|
||||||
glVertex3f(s, -s, s);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Render the right quad
|
|
||||||
// glBindTexture(GL_TEXTURE_2D, _skybox[3]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex3f(-s, -s, -s);
|
|
||||||
glTexCoord2f(0, t);
|
|
||||||
glVertex3f(-s, s, -s);
|
|
||||||
glTexCoord2f(t, t);
|
|
||||||
glVertex3f(-s, s, s);
|
|
||||||
glTexCoord2f(t, 0);
|
|
||||||
glVertex3f(-s, -s, s);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Render the top quad
|
|
||||||
//glBindTexture(GL_TEXTURE_2D, _skybox[4]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, t);
|
|
||||||
glVertex3f(-s, s, -s);
|
|
||||||
|
|
||||||
glTexCoord2f(t, t);
|
|
||||||
glVertex3f(s, s, -s);
|
|
||||||
|
|
||||||
glTexCoord2f(t, 0);
|
|
||||||
glVertex3f(s, s, s);
|
|
||||||
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex3f(-s, s, s);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Render the bottom quad
|
|
||||||
//glBindTexture(GL_TEXTURE_2D, _skybox[5]);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex3f(-s, -s, -s);
|
|
||||||
glTexCoord2f(0, t);
|
|
||||||
glVertex3f(-s, -s, s);
|
|
||||||
glTexCoord2f(t, t);
|
|
||||||
glVertex3f(s, -s, s);
|
|
||||||
glTexCoord2f(t, 0);
|
|
||||||
glVertex3f(s, -s, -s);
|
|
||||||
glEnd();
|
|
||||||
#else
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
glVertexPointer(3, GL_FLOAT, game.levelMesh->vertex_size,
|
|
||||||
game.levelMesh->vertices);
|
|
||||||
glTexCoordPointer(2, GL_FLOAT, game.levelMesh->vertex_size,
|
|
||||||
game.levelMesh->vertices + 3);
|
|
||||||
glNormalPointer(GL_FLOAT, game.levelMesh->vertex_size,
|
|
||||||
game.levelMesh->vertices + 5);
|
|
||||||
for (size_t i = 0; i < game.levelMesh->object_count; i++) {
|
|
||||||
glDrawElements(GL_TRIANGLES, game.levelMesh->objects[i].face_count * 3,
|
|
||||||
GL_UNSIGNED_SHORT,
|
|
||||||
&game.levelMesh->faces[game.levelMesh->objects[i].face_index]);
|
|
||||||
}
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Restore enable bits and matrix
|
|
||||||
glPopAttrib();
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::accelerate(double x, double y, double z) {
|
void Client::accelerate(double x, double y, double z) {
|
||||||
if (game.local_player == 0)
|
if (game.local_player == 0)
|
||||||
return;
|
return;
|
||||||
@ -365,44 +110,14 @@ void Client::loadConsoleFont() {
|
|||||||
oglf_load(&font, "data/fonts/console.fnt", font_id);
|
oglf_load(&font, "data/fonts/console.fnt", font_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::prepareFrame(double rx, double ry, double rz) {
|
void Client::initialize(Config &config) {
|
||||||
// Get window size (may be different than the requested size)
|
Application::initialize(config);
|
||||||
glfwGetWindowSize(&width, &height);
|
|
||||||
height = height > 0 ? height : 1;
|
|
||||||
|
|
||||||
// Set viewport
|
window.initialize(config);
|
||||||
glViewport(0, 0, width, height);
|
renderer.initialize(&window, config);
|
||||||
|
|
||||||
// Clear color buffer
|
loadConsoleFont();
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
//setup_explosion();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
// Select and setup the projection matrix
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
gluPerspective(60.0f, (GLfloat) width / (GLfloat) height, 1.0f, 10000.0f);
|
|
||||||
|
|
||||||
// Select and setup the modelview matrix
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
gluLookAt(camX, camY, camZ, camX + rx * 10.0f, camY + ry * 10.0f,
|
|
||||||
camZ + rz * 10.0f, 0.0f, 1.0f, 0.0f);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::initialize(Arguments &arg) {
|
|
||||||
Application::initialize(arg);
|
|
||||||
|
|
||||||
// Initialise GLFW
|
|
||||||
if (!glfwInit()) {
|
|
||||||
throw("Failed to initialize GLFW");
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_opengl();
|
|
||||||
setup_explosion();
|
|
||||||
quadratic = gluNewQuadric();
|
|
||||||
gluQuadricNormals(quadratic, GLU_SMOOTH);
|
|
||||||
gluQuadricTexture(quadratic, GL_TRUE);
|
|
||||||
|
|
||||||
if (isMaster()) {
|
if (isMaster()) {
|
||||||
Team *team = game.getTeam(0);
|
Team *team = game.getTeam(0);
|
||||||
@ -425,12 +140,132 @@ void Client::initialize(Arguments &arg) {
|
|||||||
|
|
||||||
// setup signals
|
// setup signals
|
||||||
game.ExplosionSignal.connect(this, &Client::onExplosion);
|
game.ExplosionSignal.connect(this, &Client::onExplosion);
|
||||||
|
|
||||||
|
renderer.create("level");
|
||||||
|
}
|
||||||
|
void Client::processInput(double step) {
|
||||||
|
if (!game.local_player)
|
||||||
|
return;
|
||||||
|
|
||||||
|
btRigidBody *body = game.local_player->body.get();
|
||||||
|
if (!body)
|
||||||
|
return;
|
||||||
|
|
||||||
|
btMatrix3x3 &basis = body->getWorldTransform().getBasis();
|
||||||
|
btVector3 front = basis * btVector3(0, 0, -10) * step;
|
||||||
|
btVector3 right = basis * btVector3(10, 0, 0) * step;
|
||||||
|
btVector3 up = basis * btVector3(0, 10, 0) * step;
|
||||||
|
|
||||||
|
float accelSpeed = 200 / body->getInvMass();
|
||||||
|
btVector3 accel(0, 0, 0);
|
||||||
|
if (glfwGetKey('W') == GLFW_PRESS) {
|
||||||
|
accel += accelSpeed * front;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey('A') == GLFW_PRESS) {
|
||||||
|
accel += -accelSpeed * right;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey('S') == GLFW_PRESS) {
|
||||||
|
accel += -accelSpeed * front;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey('D') == GLFW_PRESS) {
|
||||||
|
accel += accelSpeed * right;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey('R') == GLFW_PRESS) {
|
||||||
|
accel += accelSpeed * up;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey('F') == GLFW_PRESS) {
|
||||||
|
accel += -accelSpeed * up;
|
||||||
|
}
|
||||||
|
accel *= step;
|
||||||
|
accelerate(accel.x(), accel.y(), accel.z());
|
||||||
|
#if 0
|
||||||
|
float rotationSpeed = 1000 / body->getInvMass();
|
||||||
|
|
||||||
|
float lx = (mouseX - 0.5) * 2;
|
||||||
|
float ly = (mouseY - 0.5) * 2;
|
||||||
|
|
||||||
|
btVector3 desiredLocalAngualarVelocity = btVector3(0, -2 * lx, 0)
|
||||||
|
+ btVector3(-2 * ly, 0, 0);
|
||||||
|
btVector3 desiredAngualarVelocity = body->getWorldTransform().getBasis()
|
||||||
|
* desiredLocalAngualarVelocity;
|
||||||
|
btVector3 angularVelocity = body->getAngularVelocity();
|
||||||
|
btVector3 a = desiredAngualarVelocity - angularVelocity;
|
||||||
|
float turningAngle = a.length();
|
||||||
|
a *= fabs(turningAngle);
|
||||||
|
|
||||||
|
Steering *s = 0;
|
||||||
|
if (entity->getComponent(s))
|
||||||
|
s->setAngularForce(a);
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (turningAngle > 0.001) {
|
||||||
|
activate = true;
|
||||||
|
jetStrength += std::min(0.2f, turningAngle * turningAngle * 10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey(GLFW_KEY_LEFT) == GLFW_PRESS) {
|
||||||
|
body->applyForce(-rotationSpeed * right, front);
|
||||||
|
body->applyForce(rotationSpeed * right, -front);
|
||||||
|
activate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey(GLFW_KEY_RIGHT) == GLFW_PRESS) {
|
||||||
|
body->applyForce(rotationSpeed * right, front);
|
||||||
|
body->applyForce(-rotationSpeed * right, -front);
|
||||||
|
activate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey(GLFW_KEY_UP) == GLFW_PRESS) {
|
||||||
|
body->applyForce(-rotationSpeed * up, front);
|
||||||
|
body->applyForce(rotationSpeed * up, -front);
|
||||||
|
activate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey(GLFW_KEY_DOWN) == GLFW_PRESS) {
|
||||||
|
body->applyForce(rotationSpeed * up, front);
|
||||||
|
body->applyForce(-rotationSpeed * up, -front);
|
||||||
|
activate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// roll
|
||||||
|
if (glfwGetKey('Q') == GLFW_PRESS) {
|
||||||
|
body->applyForce(rotationSpeed * up, right);
|
||||||
|
body->applyForce(-rotationSpeed * up, -right);
|
||||||
|
jetStrength += 0.1;
|
||||||
|
activate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (glfwGetKey('E') == GLFW_PRESS) {
|
||||||
|
body->applyForce(-rotationSpeed * up, right);
|
||||||
|
body->applyForce(rotationSpeed * up, -right);
|
||||||
|
jetStrength += 0.1;
|
||||||
|
activate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activate) {
|
||||||
|
body->activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jetStrength > 0) {
|
||||||
|
jet->setVolume(jetStrength);
|
||||||
|
if (!jet->isPlaying()) {
|
||||||
|
jet->play2d(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jet->stop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
void Client::update() {
|
void Client::update() {
|
||||||
|
|
||||||
Application::update();
|
Application::update();
|
||||||
|
window.update();
|
||||||
int x, y;
|
int x, y;
|
||||||
glfwGetMousePos(&x, &y);
|
glfwGetMousePos(&x, &y);
|
||||||
if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_2) == GLFW_PRESS) {
|
if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_2) == GLFW_PRESS) {
|
||||||
@ -450,25 +285,7 @@ void Client::update() {
|
|||||||
|
|
||||||
if (accelerate_schudule.next(time)) {
|
if (accelerate_schudule.next(time)) {
|
||||||
double t = accelerate_schudule.getInterval();
|
double t = accelerate_schudule.getInterval();
|
||||||
double v = 50.0 * t;
|
processInput(t);
|
||||||
if (glfwGetKey('W')) {
|
|
||||||
accelerate(rx * v, ry * v, rz * v);
|
|
||||||
} else if (glfwGetKey('S')) {
|
|
||||||
accelerate(rx * -v, ry * -v, rz * -v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (glfwGetKey('A')) {
|
|
||||||
accelerate(rz * v, 0, -rx * v);
|
|
||||||
} else if (glfwGetKey('D')) {
|
|
||||||
accelerate(-rz * v, 0, rx * v);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (glfwGetKey(GLFW_KEY_SPACE)) {
|
|
||||||
accelerate(game.local_player->vx * -0.1,
|
|
||||||
game.local_player->vy * -0.1, game.local_player->vz * -0.1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (glfwGetKey(GLFW_KEY_LCTRL)) {
|
if (glfwGetKey(GLFW_KEY_LCTRL)) {
|
||||||
if (time - last_bomb > 1.0) {
|
if (time - last_bomb > 1.0) {
|
||||||
@ -477,18 +294,30 @@ void Client::update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btScalar bullet_trafo[16];
|
||||||
if (game.local_player) {
|
if (game.local_player) {
|
||||||
btVector3 p = game.local_player->body->getWorldTransform().getOrigin();
|
game.local_player->body->getWorldTransform().getOpenGLMatrix(
|
||||||
|
bullet_trafo);
|
||||||
camX = p.x();
|
// bullet_trafo[12] -= origin.x();
|
||||||
camY = p.y();
|
// bullet_trafo[13] -= origin.y();
|
||||||
camZ = p.z();
|
// bullet_trafo[14] -= origin.z();
|
||||||
} else {
|
} else {
|
||||||
camX = 1000.0;
|
bullet_trafo[12] = 1000.0;
|
||||||
camY = 1000.0;
|
bullet_trafo[13] = 1000.0;
|
||||||
camZ = 1000.0;
|
bullet_trafo[14] = 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float trafo[16];
|
||||||
|
for (size_t i = 0; i < 16; i++)
|
||||||
|
trafo[i] = bullet_trafo[i];
|
||||||
|
h3dSetNodeTransMat(renderer.getCameraNode(), trafo);
|
||||||
|
// h3dSetNodeTransform(renderer.getCameraNode(), camX, camY, camZ,
|
||||||
|
// -theta * 180 / M_PI - 90, phi * 180 / M_PI, 0, 1, 1, 1);
|
||||||
|
// H3DNode cam = renderer.getCameraNode();
|
||||||
|
|
||||||
|
renderer.draw();
|
||||||
|
|
||||||
|
#if 0
|
||||||
prepareFrame(rx, ry, rz);
|
prepareFrame(rx, ry, rz);
|
||||||
setup_light();
|
setup_light();
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
@ -511,7 +340,7 @@ void Client::update() {
|
|||||||
|
|
||||||
explosion.update(dt * 1000.0, camX, camY, camZ);
|
explosion.update(dt * 1000.0, camX, camY, camZ);
|
||||||
explosion.render();
|
explosion.render();
|
||||||
|
#endif
|
||||||
glDisable(GL_LIGHT0);
|
glDisable(GL_LIGHT0);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
@ -558,7 +387,6 @@ void Client::shutdown() {
|
|||||||
|
|
||||||
Application::shutdown();
|
Application::shutdown();
|
||||||
|
|
||||||
gluDeleteQuadric(quadratic);
|
|
||||||
oglf_destroy(&font);
|
oglf_destroy(&font);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
@ -567,3 +395,4 @@ void Client::onExplosion(double x, double y, double z) {
|
|||||||
explosion.add(x, y, z);
|
explosion.add(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
@ -10,14 +10,21 @@
|
|||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Schedule.h"
|
#include "Schedule.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
#include "oglfont.h"
|
#include "oglfont.h"
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
class Client: public Application {
|
class Client: public Application {
|
||||||
public:
|
public:
|
||||||
void initialize(Arguments &arg);
|
void initialize(Config &config);
|
||||||
void update();
|
void update();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
private:
|
private:
|
||||||
|
Window window;
|
||||||
|
Renderer renderer;
|
||||||
double last_bomb; //TODO: use bomb schedule;
|
double last_bomb; //TODO: use bomb schedule;
|
||||||
int last_x, last_y;
|
int last_x, last_y;
|
||||||
double phi, theta;
|
double phi, theta;
|
||||||
@ -26,8 +33,7 @@ private:
|
|||||||
int width, height;
|
int width, height;
|
||||||
//TrueTyeFont font;
|
//TrueTyeFont font;
|
||||||
oglf_font_t font;
|
oglf_font_t font;
|
||||||
|
void processInput(double step);
|
||||||
void prepareFrame(double rx, double ry, double rz);
|
|
||||||
void accelerate(double x, double y, double z);
|
void accelerate(double x, double y, double z);
|
||||||
void drop_bomb(double rx, double ry, double rz, double ttl);
|
void drop_bomb(double rx, double ry, double rz, double ttl);
|
||||||
void loadConsoleFont();
|
void loadConsoleFont();
|
||||||
@ -38,4 +44,6 @@ private:
|
|||||||
void drawPlayer(player_t *player);
|
void drawPlayer(player_t *player);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
|
||||||
#endif /* CLIENT_H_ */
|
#endif /* CLIENT_H_ */
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
/*
|
|
||||||
* Explosion.cpp
|
|
||||||
*
|
|
||||||
* Created on: 05.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Explosion.h"
|
#include "Explosion.h"
|
||||||
|
|
||||||
using namespace SPK;
|
using namespace SPK;
|
||||||
using namespace SPK::GL;
|
using namespace SPK::GL;
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
Explosion::~Explosion() {
|
Explosion::~Explosion() {
|
||||||
SPKFactory::getInstance().destroyAll();
|
SPKFactory::getInstance().destroyAll();
|
||||||
}
|
}
|
||||||
@ -111,9 +106,9 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
|||||||
Interpolator* interpolator = NULL; // pointer to an interpolator that is used to retrieve interpolators
|
Interpolator* interpolator = NULL; // pointer to an interpolator that is used to retrieve interpolators
|
||||||
|
|
||||||
// smoke model
|
// smoke model
|
||||||
Model* smokeModel = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE
|
Model* smokeModel = Model::create(
|
||||||
| FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX,
|
FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA | FLAG_SIZE
|
||||||
FLAG_SIZE | FLAG_ANGLE,
|
| FLAG_ANGLE | FLAG_TEXTURE_INDEX, FLAG_SIZE | FLAG_ANGLE,
|
||||||
FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX, FLAG_ALPHA);
|
FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX, FLAG_ALPHA);
|
||||||
smokeModel->setParam(PARAM_RED, 0.2f);
|
smokeModel->setParam(PARAM_RED, 0.2f);
|
||||||
smokeModel->setParam(PARAM_GREEN, 0.2f);
|
smokeModel->setParam(PARAM_GREEN, 0.2f);
|
||||||
@ -131,10 +126,11 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
|||||||
interpolator->addEntry(1.0f, 0.0f);
|
interpolator->addEntry(1.0f, 0.0f);
|
||||||
|
|
||||||
// flame model
|
// flame model
|
||||||
Model* flameModel = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE
|
Model* flameModel = Model::create(
|
||||||
| FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX,
|
FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA | FLAG_SIZE
|
||||||
FLAG_ANGLE | FLAG_RED | FLAG_GREEN | FLAG_BLUE, FLAG_ANGLE
|
| FLAG_ANGLE | FLAG_TEXTURE_INDEX,
|
||||||
| FLAG_TEXTURE_INDEX, FLAG_SIZE | FLAG_ALPHA);
|
FLAG_ANGLE | FLAG_RED | FLAG_GREEN | FLAG_BLUE,
|
||||||
|
FLAG_ANGLE | FLAG_TEXTURE_INDEX, FLAG_SIZE | FLAG_ALPHA);
|
||||||
flameModel->setParam(PARAM_RED, 1.0f, 0.2f);
|
flameModel->setParam(PARAM_RED, 1.0f, 0.2f);
|
||||||
flameModel->setParam(PARAM_GREEN, 0.5f, 0.2f);
|
flameModel->setParam(PARAM_GREEN, 0.5f, 0.2f);
|
||||||
flameModel->setParam(PARAM_BLUE, 0.2f, 0.2f);
|
flameModel->setParam(PARAM_BLUE, 0.2f, 0.2f);
|
||||||
@ -176,8 +172,9 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
|||||||
spark1Model->setShared(true);
|
spark1Model->setShared(true);
|
||||||
|
|
||||||
// spark 2 model
|
// spark 2 model
|
||||||
Model* spark2Model = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE
|
Model* spark2Model = Model::create(
|
||||||
| FLAG_ALPHA, FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA, FLAG_GREEN);
|
FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA,
|
||||||
|
FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA, FLAG_GREEN);
|
||||||
spark2Model->setParam(PARAM_ALPHA, 1.0f, 0.0f);
|
spark2Model->setParam(PARAM_ALPHA, 1.0f, 0.0f);
|
||||||
spark2Model->setParam(PARAM_RED, 1.0f);
|
spark2Model->setParam(PARAM_RED, 1.0f);
|
||||||
spark2Model->setParam(PARAM_GREEN, 1.0f, 1.0f, 0.3f, 1.0f);
|
spark2Model->setParam(PARAM_GREEN, 1.0f, 1.0f, 0.3f, 1.0f);
|
||||||
@ -186,8 +183,8 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
|||||||
spark2Model->setShared(true);
|
spark2Model->setShared(true);
|
||||||
|
|
||||||
// wave model
|
// wave model
|
||||||
Model* waveModel = Model::create(FLAG_ALPHA | FLAG_SIZE, FLAG_SIZE
|
Model* waveModel = Model::create(FLAG_ALPHA | FLAG_SIZE,
|
||||||
| FLAG_ALPHA);
|
FLAG_SIZE | FLAG_ALPHA);
|
||||||
waveModel->setParam(PARAM_SIZE, 0.0f, 4.0f);
|
waveModel->setParam(PARAM_SIZE, 0.0f, 4.0f);
|
||||||
waveModel->setParam(PARAM_ALPHA, 0.2f, 0.0f);
|
waveModel->setParam(PARAM_ALPHA, 0.2f, 0.0f);
|
||||||
waveModel->setLifeTime(0.8f, 0.8f);
|
waveModel->setLifeTime(0.8f, 0.8f);
|
||||||
@ -198,8 +195,10 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
|||||||
//////////////
|
//////////////
|
||||||
|
|
||||||
// This zone will be used by several emitters
|
// This zone will be used by several emitters
|
||||||
Sphere* explosionSphere = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f), 0.4f * scale);
|
Sphere* explosionSphere = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f),
|
||||||
Sphere* explosionSphere2 = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f), 0.4f * 2.5* scale);
|
0.4f * scale);
|
||||||
|
Sphere* explosionSphere2 = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f),
|
||||||
|
0.4f * 2.5 * scale);
|
||||||
|
|
||||||
// smoke emitter
|
// smoke emitter
|
||||||
RandomEmitter* smokeEmitter = RandomEmitter::create();
|
RandomEmitter* smokeEmitter = RandomEmitter::create();
|
||||||
@ -302,8 +301,8 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
|||||||
void Explosion::render() {
|
void Explosion::render() {
|
||||||
GLRenderer::saveGLStates();
|
GLRenderer::saveGLStates();
|
||||||
// Renders all the particle systems
|
// Renders all the particle systems
|
||||||
for (std::list<System*>::const_iterator it = particleSystems.begin(); it
|
for (std::list<System*>::const_iterator it = particleSystems.begin();
|
||||||
!= particleSystems.end(); ++it)
|
it != particleSystems.end(); ++it)
|
||||||
(*it)->render();
|
(*it)->render();
|
||||||
GLRenderer::restoreGLStates();
|
GLRenderer::restoreGLStates();
|
||||||
}
|
}
|
||||||
@ -349,3 +348,5 @@ void Explosion::update(double dt, double cx, double cy, double cz) {
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include "SPK.h"
|
#include "SPK.h"
|
||||||
#include "SPK_GL.h"
|
#include "SPK_GL.h"
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
class Explosion {
|
class Explosion {
|
||||||
public:
|
public:
|
||||||
~Explosion();
|
~Explosion();
|
||||||
@ -24,4 +26,6 @@ private:
|
|||||||
std::list<SPK::System*> particleSystems;
|
std::list<SPK::System*> particleSystems;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
|
||||||
#endif /* EXPLOSION_H_ */
|
#endif /* EXPLOSION_H_ */
|
||||||
|
@ -20,9 +20,11 @@ int main(int argc, const char **argv) {
|
|||||||
LOG4CPLUS_INFO(logger, " - " << argv[i]);
|
LOG4CPLUS_INFO(logger, " - " << argv[i]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Client app;
|
gln::Client app;
|
||||||
Arguments args(argc, argv);
|
gln::Config config;
|
||||||
app.initialize(args);
|
config.load(argc, argv);
|
||||||
|
|
||||||
|
app.initialize(config);
|
||||||
while (app.isRunning())
|
while (app.isRunning())
|
||||||
app.update();
|
app.update();
|
||||||
app.shutdown();
|
app.shutdown();
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
/*
|
|
||||||
* Application.cpp
|
|
||||||
*
|
|
||||||
* Created on: 14.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Time.h"
|
#include "Time.h"
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
Application::Application() :
|
Application::Application() :
|
||||||
running(false), master(false), time(0.0), network(&game) {
|
running(false), master(false), time(0.0), network(&game) {
|
||||||
|
|
||||||
@ -34,7 +29,7 @@ void Application::stop() {
|
|||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initialize(Arguments &arg) {
|
void Application::initialize(Config &config) {
|
||||||
std::cout << "[Application] initialize" << std::endl;
|
std::cout << "[Application] initialize" << std::endl;
|
||||||
|
|
||||||
// setup time
|
// setup time
|
||||||
@ -49,7 +44,8 @@ void Application::initialize(Arguments &arg) {
|
|||||||
gameUpdateSchudule.setExact(true);
|
gameUpdateSchudule.setExact(true);
|
||||||
gameUpdateSchudule.setInterval(0.05);
|
gameUpdateSchudule.setInterval(0.05);
|
||||||
|
|
||||||
std::string host = arg.getString("-h", std::string());
|
std::string host;
|
||||||
|
config.get("host", host);
|
||||||
network.initialize(host);
|
network.initialize(host);
|
||||||
|
|
||||||
// setup network
|
// setup network
|
||||||
@ -89,3 +85,5 @@ void Application::setMaster(bool master) {
|
|||||||
this->master = master;
|
this->master = master;
|
||||||
game.set_master(master ? 1 : 0);
|
game.set_master(master ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
/*
|
|
||||||
* Application.h
|
|
||||||
*
|
|
||||||
* Created on: 14.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef APPLICATION_H_
|
#ifndef APPLICATION_H_
|
||||||
#define APPLICATION_H_
|
#define APPLICATION_H_
|
||||||
|
|
||||||
@ -13,14 +6,16 @@
|
|||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Schedule.h"
|
#include "Schedule.h"
|
||||||
#include "Arguments.h"
|
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
class Application: public sigslot::has_slots<> {
|
class Application: public sigslot::has_slots<> {
|
||||||
public:
|
public:
|
||||||
Application();
|
Application();
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
virtual void initialize(Arguments &arg);
|
virtual void initialize(Config &config);
|
||||||
virtual void update();
|
virtual void update();
|
||||||
virtual void shutdown();
|
virtual void shutdown();
|
||||||
|
|
||||||
@ -50,4 +45,6 @@ protected:
|
|||||||
double time;
|
double time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
|
||||||
#endif /* APPLICATION_H_ */
|
#endif /* APPLICATION_H_ */
|
||||||
|
@ -6,6 +6,7 @@ add_library( common
|
|||||||
Game
|
Game
|
||||||
Time
|
Time
|
||||||
Network
|
Network
|
||||||
|
Config
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies( common
|
add_dependencies( common
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "btBulletDynamicsCommon.h"
|
namespace gln {
|
||||||
|
|
||||||
Game::Game() :
|
Game::Game() :
|
||||||
local_player(0), collisionConfiguration(
|
local_player(0), collisionConfiguration(
|
||||||
new btDefaultCollisionConfiguration()), dispatcher(
|
new btDefaultCollisionConfiguration()), dispatcher(
|
||||||
new btCollisionDispatcher(collisionConfiguration.get())),
|
new btCollisionDispatcher(collisionConfiguration.get())), overlappingPairCache(
|
||||||
overlappingPairCache(new btDbvtBroadphase), solver(
|
new btDbvtBroadphase), solver(
|
||||||
new btSequentialImpulseConstraintSolver), dynamicsWorld(
|
new btSequentialImpulseConstraintSolver), dynamicsWorld(
|
||||||
new btDiscreteDynamicsWorld(dispatcher.get(),
|
new btDiscreteDynamicsWorld(dispatcher.get(),
|
||||||
overlappingPairCache.get(), solver.get(),
|
overlappingPairCache.get(), solver.get(),
|
||||||
@ -39,8 +40,8 @@ void reset_player(player_t *player) {
|
|||||||
if (player->body.get() == 0)
|
if (player->body.get() == 0)
|
||||||
return;
|
return;
|
||||||
if (player->team) {
|
if (player->team) {
|
||||||
player->body->getWorldTransform().setOrigin(btVector3(player->team->x,
|
player->body->getWorldTransform().setOrigin(
|
||||||
player->team->y, player->team->z));
|
btVector3(player->team->x, player->team->y, player->team->z));
|
||||||
} else {
|
} else {
|
||||||
player->body->getWorldTransform().setOrigin(btVector3(0, 0, 0));
|
player->body->getWorldTransform().setOrigin(btVector3(0, 0, 0));
|
||||||
}
|
}
|
||||||
@ -96,8 +97,8 @@ void setup_bomb(bomb_t *bomb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::loadLevelShape() {
|
void Game::loadLevelShape() {
|
||||||
levelMesh = tlLoadTrimesh("data/level.obj", TL_FVF_XYZ | TL_FVF_UV
|
levelMesh = tlLoadTrimesh("data/level.obj",
|
||||||
| TL_FVF_NORMAL);
|
TL_FVF_XYZ | TL_FVF_UV | TL_FVF_NORMAL);
|
||||||
|
|
||||||
if (levelMesh == 0)
|
if (levelMesh == 0)
|
||||||
throw("level mesh not found! (data/level.obj)");
|
throw("level mesh not found! (data/level.obj)");
|
||||||
@ -124,8 +125,8 @@ void Game::loadLevelShape() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::loadShipShape() {
|
void Game::loadShipShape() {
|
||||||
shipMesh = tlLoadTrimesh("data/ship.obj", TL_FVF_XYZ | TL_FVF_UV
|
shipMesh = tlLoadTrimesh("data/ship.obj",
|
||||||
| TL_FVF_NORMAL);
|
TL_FVF_XYZ | TL_FVF_UV | TL_FVF_NORMAL);
|
||||||
/*
|
/*
|
||||||
btIndexedMesh sim;
|
btIndexedMesh sim;
|
||||||
sim.m_numTriangles = shipMesh->face_count;
|
sim.m_numTriangles = shipMesh->face_count;
|
||||||
@ -151,8 +152,9 @@ void Game::loadShipShape() {
|
|||||||
|
|
||||||
shipShape.reset(_shipShape);
|
shipShape.reset(_shipShape);
|
||||||
*/
|
*/
|
||||||
shipShape.reset(new btBoxShape(btVector3(btScalar(1.5), btScalar(1.5),
|
shipShape.reset(
|
||||||
btScalar(1.5))));
|
new btBoxShape(
|
||||||
|
btVector3(btScalar(1.5), btScalar(1.5), btScalar(1.5))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setupLevel() {
|
void Game::setupLevel() {
|
||||||
@ -283,8 +285,8 @@ void Game::update_players(double dt) {
|
|||||||
p->state->getWorldTransform(player_transform);
|
p->state->getWorldTransform(player_transform);
|
||||||
player_transform.getOpenGLMatrix(p->m);
|
player_transform.getOpenGLMatrix(p->m);
|
||||||
|
|
||||||
double distance2 =
|
double distance2 = player_transform.getOrigin().distance2(
|
||||||
player_transform.getOrigin().distance2(team_position);
|
team_position);
|
||||||
if (distance2 < 10000) {
|
if (distance2 < 10000) {
|
||||||
p->team->points += p->points;
|
p->team->points += p->points;
|
||||||
p->points = 0;
|
p->points = 0;
|
||||||
@ -478,3 +480,5 @@ point_t *Game::spawn_point() {
|
|||||||
void Game::set_master(int master) {
|
void Game::set_master(int master) {
|
||||||
this->master = master;
|
this->master = master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
@ -20,6 +20,8 @@ class btTriangleIndexVertexArray;
|
|||||||
class btRigidBody;
|
class btRigidBody;
|
||||||
class btMotionState;
|
class btMotionState;
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
typedef struct Team Team;
|
typedef struct Team Team;
|
||||||
typedef struct player_t player_t;
|
typedef struct player_t player_t;
|
||||||
class Game;
|
class Game;
|
||||||
@ -122,4 +124,6 @@ private:
|
|||||||
Schedule slaveUpdate;
|
Schedule slaveUpdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
/*
|
|
||||||
* network.cpp
|
|
||||||
*
|
|
||||||
* Created on: 12.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
|
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
@ -14,6 +7,8 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
Network::Network(Game *game) :
|
Network::Network(Game *game) :
|
||||||
game(game), client_peer(0) {
|
game(game), client_peer(0) {
|
||||||
}
|
}
|
||||||
@ -56,8 +51,8 @@ void Network::initialize(const std::string &hostname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Wait up to 5 seconds for the connection attempt to succeed. */
|
/* Wait up to 5 seconds for the connection attempt to succeed. */
|
||||||
if (enet_host_service(host, &event, 2000) > 0 && event.type
|
if (enet_host_service(host, &event, 2000) > 0
|
||||||
== ENET_EVENT_TYPE_CONNECT) {
|
&& event.type == ENET_EVENT_TYPE_CONNECT) {
|
||||||
std::cout << "[Network] connected" << std::endl;
|
std::cout << "[Network] connected" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
/* Either the 5 seconds are up or a disconnect event was */
|
/* Either the 5 seconds are up or a disconnect event was */
|
||||||
@ -134,126 +129,77 @@ T *_message_cast(void *p, size_t l) {
|
|||||||
#define EMIT_END() out << YAML::EndMap;return out;}
|
#define EMIT_END() out << YAML::EndMap;return out;}
|
||||||
|
|
||||||
// player_spawn_message_t
|
// player_spawn_message_t
|
||||||
EMIT_START(player_spawn_message_t)
|
EMIT_START(player_spawn_message_t) EMIT_FIELD(team_id)EMIT_FIELD(player_id)
|
||||||
EMIT_FIELD(team_id)
|
|
||||||
EMIT_FIELD(player_id)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(player_spawn_message_t) PARSE_FIELD(team_id)
|
PARSE_START(player_spawn_message_t) PARSE_FIELD(team_id)
|
||||||
PARSE_FIELD(player_id)PARSE_END()
|
PARSE_FIELD(player_id)PARSE_END()
|
||||||
|
|
||||||
// player_kill_message_t
|
// player_kill_message_t
|
||||||
EMIT_START(player_kill_message_t)
|
EMIT_START(player_kill_message_t) EMIT_FIELD(player_id)
|
||||||
EMIT_FIELD(player_id)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(player_kill_message_t) PARSE_FIELD(player_id)PARSE_END()
|
PARSE_START(player_kill_message_t) PARSE_FIELD(player_id)PARSE_END()
|
||||||
|
|
||||||
// accept_message_t
|
// accept_message_t
|
||||||
EMIT_START(accept_message_t)
|
EMIT_START(accept_message_t) EMIT_FIELD(player_id)
|
||||||
EMIT_FIELD(player_id)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(accept_message_t) PARSE_FIELD(player_id)PARSE_END()
|
PARSE_START(accept_message_t) PARSE_FIELD(player_id)PARSE_END()
|
||||||
|
|
||||||
// player_update_message_t
|
// player_update_message_t
|
||||||
EMIT_START(player_update_message_t)
|
EMIT_START(player_update_message_t) EMIT_FIELD(player_id)EMIT_FIELD(x)EMIT_FIELD(
|
||||||
EMIT_FIELD(player_id)
|
y)EMIT_FIELD(z)EMIT_FIELD(vx)EMIT_FIELD(vy)EMIT_FIELD(vz)EMIT_FIELD(
|
||||||
EMIT_FIELD(x)
|
points)
|
||||||
EMIT_FIELD(y)
|
|
||||||
EMIT_FIELD(z)
|
|
||||||
EMIT_FIELD(vx)
|
|
||||||
EMIT_FIELD(vy)
|
|
||||||
EMIT_FIELD(vz)
|
|
||||||
EMIT_FIELD(points)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(player_update_message_t) PARSE_FIELD(player_id)
|
PARSE_START(player_update_message_t) PARSE_FIELD(player_id)PARSE_FIELD(x)PARSE_FIELD(
|
||||||
PARSE_FIELD(x)
|
y)PARSE_FIELD(z)PARSE_FIELD(vx)PARSE_FIELD(vy)PARSE_FIELD(vz)
|
||||||
PARSE_FIELD(y)
|
|
||||||
PARSE_FIELD(z)
|
|
||||||
PARSE_FIELD(vx)
|
|
||||||
PARSE_FIELD(vy)
|
|
||||||
PARSE_FIELD(vz)
|
|
||||||
PARSE_FIELD(points)PARSE_END()
|
PARSE_FIELD(points)PARSE_END()
|
||||||
|
|
||||||
// player_accelerate_message_t
|
// player_accelerate_message_t
|
||||||
EMIT_START(player_accelerate_message_t)
|
EMIT_START(player_accelerate_message_t) EMIT_FIELD(player_id)EMIT_FIELD(x)EMIT_FIELD(
|
||||||
EMIT_FIELD(player_id)
|
y)EMIT_FIELD(z)EMIT_FIELD(rx)EMIT_FIELD( ry)EMIT_FIELD(rz)
|
||||||
EMIT_FIELD(x)
|
|
||||||
EMIT_FIELD(y)
|
|
||||||
EMIT_FIELD(z)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(player_accelerate_message_t) PARSE_FIELD(player_id)
|
PARSE_START(player_accelerate_message_t) PARSE_FIELD(player_id)PARSE_FIELD(x)PARSE_FIELD(
|
||||||
PARSE_FIELD(x)
|
y)PARSE_FIELD(rx)PARSE_FIELD( ry)
|
||||||
PARSE_FIELD(y)
|
PARSE_FIELD(rz)PARSE_END()
|
||||||
PARSE_FIELD(z)PARSE_END()
|
|
||||||
|
|
||||||
// bomb_drop_meesage_t
|
// bomb_drop_meesage_t
|
||||||
EMIT_START(bomb_drop_meesage_t)
|
EMIT_START(bomb_drop_meesage_t) EMIT_FIELD(x)EMIT_FIELD(y)EMIT_FIELD(z)EMIT_FIELD(
|
||||||
EMIT_FIELD(x)
|
vx)EMIT_FIELD(vy)EMIT_FIELD(vz)EMIT_FIELD(ttl)
|
||||||
EMIT_FIELD(y)
|
|
||||||
EMIT_FIELD(z)
|
|
||||||
EMIT_FIELD(vx)
|
|
||||||
EMIT_FIELD(vy)
|
|
||||||
EMIT_FIELD(vz)
|
|
||||||
EMIT_FIELD(ttl)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(bomb_drop_meesage_t) PARSE_FIELD(x)
|
PARSE_START(bomb_drop_meesage_t) PARSE_FIELD(x)PARSE_FIELD(y)PARSE_FIELD(z)PARSE_FIELD(
|
||||||
PARSE_FIELD(y)
|
vx)PARSE_FIELD(vy)PARSE_FIELD(vz)
|
||||||
PARSE_FIELD(z)
|
|
||||||
PARSE_FIELD(vx)
|
|
||||||
PARSE_FIELD(vy)
|
|
||||||
PARSE_FIELD(vz)
|
|
||||||
PARSE_FIELD(ttl)PARSE_END()
|
PARSE_FIELD(ttl)PARSE_END()
|
||||||
|
|
||||||
// bomb_update_meesage_t
|
// bomb_update_meesage_t
|
||||||
EMIT_START(bomb_update_meesage_t)
|
EMIT_START(bomb_update_meesage_t) EMIT_FIELD(bomb_index)EMIT_FIELD(x)EMIT_FIELD(
|
||||||
EMIT_FIELD(bomb_index)
|
y)EMIT_FIELD(z)EMIT_FIELD(vx)EMIT_FIELD(vy)EMIT_FIELD(vz)EMIT_FIELD(
|
||||||
EMIT_FIELD(x)
|
ttl)
|
||||||
EMIT_FIELD(y)
|
|
||||||
EMIT_FIELD(z)
|
|
||||||
EMIT_FIELD(vx)
|
|
||||||
EMIT_FIELD(vy)
|
|
||||||
EMIT_FIELD(vz)
|
|
||||||
EMIT_FIELD(ttl)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(bomb_update_meesage_t) PARSE_FIELD(bomb_index)
|
PARSE_START(bomb_update_meesage_t) PARSE_FIELD(bomb_index)PARSE_FIELD(x)PARSE_FIELD(
|
||||||
PARSE_FIELD(x)
|
y)PARSE_FIELD(z)PARSE_FIELD(vx)PARSE_FIELD(vy)PARSE_FIELD(vz)
|
||||||
PARSE_FIELD(y)
|
|
||||||
PARSE_FIELD(z)
|
|
||||||
PARSE_FIELD(vx)
|
|
||||||
PARSE_FIELD(vy)
|
|
||||||
PARSE_FIELD(vz)
|
|
||||||
PARSE_FIELD(ttl)PARSE_END()
|
PARSE_FIELD(ttl)PARSE_END()
|
||||||
|
|
||||||
// point_update_mesage_t
|
// point_update_mesage_t
|
||||||
EMIT_START(point_update_mesage_t)
|
EMIT_START(point_update_mesage_t) EMIT_FIELD(point_index)EMIT_FIELD(x)EMIT_FIELD(
|
||||||
EMIT_FIELD(point_index)
|
y)EMIT_FIELD(z)EMIT_FIELD(status)
|
||||||
EMIT_FIELD(x)
|
|
||||||
EMIT_FIELD(y)
|
|
||||||
EMIT_FIELD(z)
|
|
||||||
EMIT_FIELD(status)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(point_update_mesage_t) PARSE_FIELD(point_index)
|
PARSE_START(point_update_mesage_t) PARSE_FIELD(point_index)PARSE_FIELD(x)PARSE_FIELD(
|
||||||
PARSE_FIELD(x)
|
y)PARSE_FIELD(z)
|
||||||
PARSE_FIELD(y)
|
|
||||||
PARSE_FIELD(z)
|
|
||||||
PARSE_FIELD(status)PARSE_END()
|
PARSE_FIELD(status)PARSE_END()
|
||||||
|
|
||||||
// team_update_message_t
|
// team_update_message_t
|
||||||
EMIT_START(team_update_message_t)
|
EMIT_START(team_update_message_t) EMIT_FIELD(team_id)EMIT_FIELD(points)EMIT_FIELD(
|
||||||
EMIT_FIELD(team_id)
|
wins)
|
||||||
EMIT_FIELD(points)
|
|
||||||
EMIT_FIELD(wins)
|
|
||||||
EMIT_END()
|
EMIT_END()
|
||||||
|
|
||||||
PARSE_START(team_update_message_t) PARSE_FIELD(team_id)
|
PARSE_START(team_update_message_t) PARSE_FIELD(team_id)PARSE_FIELD(points)
|
||||||
PARSE_FIELD(points)
|
|
||||||
PARSE_FIELD(wins)PARSE_END()
|
PARSE_FIELD(wins)PARSE_END()
|
||||||
|
|
||||||
void Network::dispatch(enet_uint8 *data, size_t length) {
|
void Network::dispatch(enet_uint8 *data, size_t length) {
|
||||||
@ -418,9 +364,8 @@ void Network::service(uint32_t timeout) {
|
|||||||
spwan_msg.player_id = game->player[i].id;
|
spwan_msg.player_id = game->player[i].id;
|
||||||
YAML::Emitter em;
|
YAML::Emitter em;
|
||||||
em << spwan_msg;
|
em << spwan_msg;
|
||||||
ENetPacket * packet = enet_packet_create(
|
ENetPacket * packet = enet_packet_create((uint8_t *) em.c_str(),
|
||||||
(uint8_t *) em.c_str(), em.size(),
|
em.size(), ENET_PACKET_FLAG_RELIABLE);
|
||||||
ENET_PACKET_FLAG_RELIABLE);
|
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,9 +381,8 @@ void Network::service(uint32_t timeout) {
|
|||||||
YAML::Emitter em;
|
YAML::Emitter em;
|
||||||
em << msg;
|
em << msg;
|
||||||
|
|
||||||
ENetPacket * packet = enet_packet_create(
|
ENetPacket * packet = enet_packet_create((uint8_t *) em.c_str(),
|
||||||
(uint8_t *) em.c_str(), em.size(),
|
em.size(), ENET_PACKET_FLAG_RELIABLE);
|
||||||
ENET_PACKET_FLAG_RELIABLE);
|
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,9 +397,8 @@ void Network::service(uint32_t timeout) {
|
|||||||
YAML::Emitter em;
|
YAML::Emitter em;
|
||||||
em << spwan_msg;
|
em << spwan_msg;
|
||||||
|
|
||||||
ENetPacket * packet = enet_packet_create(
|
ENetPacket * packet = enet_packet_create((uint8_t *) em.c_str(),
|
||||||
(uint8_t *) em.c_str(), em.size(),
|
em.size(), ENET_PACKET_FLAG_RELIABLE);
|
||||||
ENET_PACKET_FLAG_RELIABLE);
|
|
||||||
enet_host_broadcast(host, 0, packet);
|
enet_host_broadcast(host, 0, packet);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -465,9 +408,8 @@ void Network::service(uint32_t timeout) {
|
|||||||
YAML::Emitter em;
|
YAML::Emitter em;
|
||||||
em << msg;
|
em << msg;
|
||||||
|
|
||||||
ENetPacket * packet = enet_packet_create(
|
ENetPacket * packet = enet_packet_create((uint8_t *) em.c_str(),
|
||||||
(uint8_t *) em.c_str(), em.size(),
|
em.size(), ENET_PACKET_FLAG_RELIABLE);
|
||||||
ENET_PACKET_FLAG_RELIABLE);
|
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
}
|
}
|
||||||
// send state
|
// send state
|
||||||
@ -527,3 +469,5 @@ void Network::sendMessage(uint8_t *data, size_t length) {
|
|||||||
dispatch(data, length);
|
dispatch(data, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace grln
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
/*
|
|
||||||
* network.h
|
|
||||||
*
|
|
||||||
* Created on: 12.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NETWORK_H_
|
#ifndef NETWORK_H_
|
||||||
#define NETWORK_H_
|
#define NETWORK_H_
|
||||||
|
|
||||||
@ -16,6 +9,8 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
#define EMIT_DEFINE(msg) YAML::Emitter& operator <<(YAML::Emitter& out, const msg& m);
|
#define EMIT_DEFINE(msg) YAML::Emitter& operator <<(YAML::Emitter& out, const msg& m);
|
||||||
|
|
||||||
#define MESSAGE_PLAYER_SPAWN 0
|
#define MESSAGE_PLAYER_SPAWN 0
|
||||||
@ -71,6 +66,7 @@ struct player_accelerate_message_t {
|
|||||||
};
|
};
|
||||||
uint16_t player_id;
|
uint16_t player_id;
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
|
double rx, ry, rz;
|
||||||
};
|
};
|
||||||
EMIT_DEFINE(player_accelerate_message_t)
|
EMIT_DEFINE(player_accelerate_message_t)
|
||||||
|
|
||||||
@ -131,4 +127,6 @@ protected:
|
|||||||
ENetPeer *client_peer;
|
ENetPeer *client_peer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace gln
|
||||||
|
|
||||||
#endif /* NETWORK_H_ */
|
#endif /* NETWORK_H_ */
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
/*
|
|
||||||
* Schedule.h
|
|
||||||
*
|
|
||||||
* Created on: 12.06.2010
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SCHEDULE_H_
|
#ifndef SCHEDULE_H_
|
||||||
#define SCHEDULE_H_
|
#define SCHEDULE_H_
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
class Schedule {
|
class Schedule {
|
||||||
double last;
|
double last;
|
||||||
@ -53,4 +47,5 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} // namespace grln
|
||||||
#endif /* SCHEDULE_H_ */
|
#endif /* SCHEDULE_H_ */
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
/*
|
|
||||||
* Timer.cpp
|
|
||||||
*
|
|
||||||
* Created on: 12.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Time.h"
|
#include "Time.h"
|
||||||
|
namespace gln {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#define MEAN_AND_LEAN
|
#define MEAN_AND_LEAN
|
||||||
@ -128,3 +121,4 @@ void PerformanceTimer::set(double t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // else _WIN32
|
#endif // else _WIN32
|
||||||
|
} // namespace grln
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
/*
|
|
||||||
* Timer.h
|
|
||||||
*
|
|
||||||
* Created on: 12.01.2011
|
|
||||||
* Author: gmueller
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TIME_H_
|
#ifndef TIME_H_
|
||||||
#define TIME_H_
|
#define TIME_H_
|
||||||
|
namespace gln {
|
||||||
|
|
||||||
class PerformanceTimer {
|
class PerformanceTimer {
|
||||||
public:
|
public:
|
||||||
static double get();
|
static double get();
|
||||||
static void set(double);
|
static void set(double);
|
||||||
};
|
};
|
||||||
|
} // namespace grln
|
||||||
#endif /* TIME_H_ */
|
#endif /* TIME_H_ */
|
||||||
|
@ -3,18 +3,21 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
Application app;
|
#include "Config.h"
|
||||||
|
|
||||||
|
gln::Application app;
|
||||||
|
|
||||||
void terminate(int param) {
|
void terminate(int param) {
|
||||||
app.stop();
|
app.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
Arguments args(argc, argv);
|
gln::Config config;
|
||||||
|
config.load(argc, argv);
|
||||||
try {
|
try {
|
||||||
::signal(SIGTERM, terminate);
|
::signal(SIGTERM, terminate);
|
||||||
app.setMaster(true);
|
app.setMaster(true);
|
||||||
app.initialize(args);
|
app.initialize(config);
|
||||||
while (app.isRunning())
|
while (app.isRunning())
|
||||||
app.update();
|
app.update();
|
||||||
app.shutdown();
|
app.shutdown();
|
||||||
|
Loading…
Reference in New Issue
Block a user