minor changes
This commit is contained in:
parent
dafe52c4cd
commit
dbed4abb0b
@ -1,3 +1,5 @@
|
||||
|
||||
syntax: regexp
|
||||
^build$
|
||||
syntax: regexp
|
||||
^libs/log4cplus/src/Makefile\.am$
|
@ -16,6 +16,7 @@ endif(UNIX)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/glfw/include)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/spark/include)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/enet/include)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/log4cplus/include)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/bullet)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/yaml-cpp/include)
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/libs/trimeshloader/include)
|
||||
@ -26,6 +27,7 @@ add_subdirectory (libs/enet)
|
||||
add_subdirectory (libs/pugixml)
|
||||
add_subdirectory (libs/bullet)
|
||||
add_subdirectory (libs/yaml-cpp)
|
||||
add_subdirectory (libs/log4cplus)
|
||||
add_subdirectory (libs/trimeshloader)
|
||||
add_subdirectory (src/common)
|
||||
add_subdirectory (src/server)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "Explosion.h"
|
||||
#include "Time.h"
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include <GL/glfw.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@ -30,9 +31,9 @@ void setup_light() {
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
|
||||
glEnable( GL_LIGHT0);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glEnable( GL_LIGHTING);
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
void setup_opengl() {
|
||||
@ -49,14 +50,14 @@ void setup_opengl() {
|
||||
glfwEnable(GLFW_STICKY_KEYS);
|
||||
|
||||
// general settings
|
||||
glShadeModel( GL_SMOOTH);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glEnable( GL_CULL_FACE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
// setup depth buffer
|
||||
glClearDepth(1.0f);
|
||||
glEnable( GL_DEPTH_TEST);
|
||||
glDepthFunc( GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
// Enable vertical sync (on cards that support it)
|
||||
glfwSwapInterval(0);
|
||||
@ -65,7 +66,7 @@ void setup_opengl() {
|
||||
void draw_team(Team *team) {
|
||||
size_t i = 0;
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, team->color);
|
||||
glMatrixMode( GL_MODELVIEW);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslated(team->x, team->y, team->z);
|
||||
gluSphere(quadratic, 50.f, 32, 32);
|
||||
@ -76,12 +77,12 @@ void Client::drawPlayer(player_t *player) {
|
||||
if (player->status == 0)
|
||||
return;
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, player->team->color);
|
||||
glMatrixMode( GL_MODELVIEW);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glMultMatrixf(player->m);
|
||||
glEnableClientState( GL_VERTEX_ARRAY);
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState( GL_NORMAL_ARRAY);
|
||||
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,
|
||||
@ -103,18 +104,19 @@ void draw_bomb(bomb_t *bomb) {
|
||||
return;
|
||||
GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glMatrixMode( GL_MODELVIEW);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslated(bomb->x, bomb->y, bomb->z);
|
||||
gluSphere(quadratic, 3.f, 4, 4);
|
||||
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);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslated(point->x, point->y, point->z);
|
||||
gluSphere(quadratic, 3.f, 12, 12);
|
||||
@ -172,7 +174,7 @@ void Client::drawLevel() {
|
||||
if (wallTex == 0) {
|
||||
glGenTextures(1, &wallTex);
|
||||
glBindTexture(GL_TEXTURE_2D, wallTex);
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
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);
|
||||
@ -181,20 +183,20 @@ void Client::drawLevel() {
|
||||
glfwLoadTexture2D("data/wall.tga", GLFW_BUILD_MIPMAPS_BIT);
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, wallTex);
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
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);
|
||||
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);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
#if 0
|
||||
glTranslated(2000.0, 0.0, 0.0);
|
||||
@ -293,9 +295,9 @@ void Client::drawLevel() {
|
||||
glVertex3f(s, -s, -s);
|
||||
glEnd();
|
||||
#else
|
||||
glEnableClientState( GL_VERTEX_ARRAY);
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState( GL_NORMAL_ARRAY);
|
||||
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,
|
||||
@ -328,21 +330,24 @@ void Client::accelerate(double x, double y, double z) {
|
||||
m << msg;
|
||||
network.send(m);
|
||||
}
|
||||
#if 0
|
||||
|
||||
void Client::drop_bomb(double rx, double ry, double rz, double ttl) {
|
||||
bomb_drop_meesage_t msg;
|
||||
msg.x = game.local_player->x + rx * 20;
|
||||
msg.y = game.local_player->y + ry * 20;
|
||||
msg.z = game.local_player->z + rz * 20;
|
||||
msg.vx = game.local_player->vx + rx * 100;
|
||||
msg.vy = game.local_player->vy + ry * 100;
|
||||
msg.vz = game.local_player->vz + rz * 100;
|
||||
btVector3 p = game.local_player->body->getWorldTransform().getOrigin();
|
||||
btVector3 v = game.local_player->body->getLinearVelocity();
|
||||
|
||||
msg.x = p.x() + rx * 1;
|
||||
msg.y = p.y() + ry * 1;
|
||||
msg.z = p.z() + rz * 1;
|
||||
msg.vx = v.x() + rx * 500;
|
||||
msg.vy = v.y() + ry * 500;
|
||||
msg.vz = v.z() + rz * 500;
|
||||
msg.ttl = ttl;
|
||||
YAML::Emitter m;
|
||||
m << msg;
|
||||
network.send(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Client::loadConsoleFont() {
|
||||
GLuint font_id = 0;
|
||||
|
||||
@ -373,15 +378,15 @@ void Client::prepareFrame(double rx, double ry, double rz) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Select and setup the projection matrix
|
||||
glMatrixMode( GL_PROJECTION);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60.0f, (GLfloat) width / (GLfloat) height, 1.0f, 10000.0f);
|
||||
|
||||
// Select and setup the modelview matrix
|
||||
glMatrixMode( GL_MODELVIEW);
|
||||
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);
|
||||
gluLookAt(camX, camY, camZ, camX + rx * 10.0f, camY + ry * 10.0f,
|
||||
camZ + rz * 10.0f, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
}
|
||||
|
||||
@ -413,6 +418,9 @@ void Client::initialize(Arguments &arg) {
|
||||
accelerate_schudule.setExact(true);
|
||||
accelerate_schudule.setInterval(0.05);
|
||||
|
||||
theta = 0.0;
|
||||
phi = 0.0;
|
||||
|
||||
loadConsoleFont();
|
||||
|
||||
// setup signals
|
||||
@ -435,6 +443,7 @@ void Client::update() {
|
||||
}
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
|
||||
double rx = cos(phi) * cos(theta);
|
||||
double ry = sin(theta);
|
||||
double rz = sin(phi) * cos(theta);
|
||||
@ -453,55 +462,59 @@ void Client::update() {
|
||||
} 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);
|
||||
accelerate(game.local_player->vx * -0.1,
|
||||
game.local_player->vy * -0.1, game.local_player->vz * -0.1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
if (glfwGetKey(GLFW_KEY_LCTRL)) {
|
||||
if (time - last_bomb > 1.0) {
|
||||
last_bomb = time;
|
||||
drop_bomb(rx, ry, rz, 5.0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (game.local_player) {
|
||||
camX = game.local_player->m[12];
|
||||
camY = game.local_player->m[13];
|
||||
camZ = game.local_player->m[14];
|
||||
btVector3 p = game.local_player->body->getWorldTransform().getOrigin();
|
||||
|
||||
camX = p.x();
|
||||
camY = p.y();
|
||||
camZ = p.z();
|
||||
} else {
|
||||
camX = 1000.0;
|
||||
camY = 1000.0;
|
||||
camZ = 1000.0;
|
||||
}
|
||||
|
||||
prepareFrame(rx, ry, rz);
|
||||
setup_light();
|
||||
glEnable( GL_LIGHT0);
|
||||
glEnable( GL_LIGHTING);
|
||||
glEnable( GL_CULL_FACE);
|
||||
glDisable( GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
// for (size_t i = 0; i < game.teams.size(); i++)
|
||||
// draw_team(&game.teams[i]);
|
||||
|
||||
for (size_t i = 0; i < GAME_PLAYER_COUNT; i++)
|
||||
drawPlayer(&game.player[i]);
|
||||
|
||||
// for (size_t i = 0; i < GAME_BOMB_COUNT; i++)
|
||||
// draw_bomb(&game.bomb[i]);
|
||||
for (size_t i = 0; i < GAME_BOMB_COUNT; i++)
|
||||
draw_bomb(&game.bomb[i]);
|
||||
//
|
||||
// for (size_t i = 0; i < GAME_POINT_COUNT; i++)
|
||||
// draw_point(&game.point[i]);
|
||||
|
||||
drawLevel();
|
||||
|
||||
explosion.update(dt * 1000.0, camX, camY, camZ);
|
||||
explosion.render();
|
||||
|
||||
glDisable(GL_LIGHT0);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_CULL_FACE);
|
||||
explosion.update(dt * 1000.0, camX, camY, camZ);
|
||||
explosion.render();
|
||||
oglf_begin(&font, width, height);
|
||||
size_t fy = 1;
|
||||
if (game.local_player) {
|
||||
@ -523,8 +536,8 @@ void Client::update() {
|
||||
|
||||
{
|
||||
std::stringstream sstr;
|
||||
sstr << "FPS: " << (int) (1 / dt) << " Time: " << floor(dt * 10000.0
|
||||
+ 0.5) / 10.0;
|
||||
sstr << "FPS: " << (int) (1 / dt) << " Time: "
|
||||
<< floor(dt * 10000.0 + 0.5) / 10.0;
|
||||
oglf_print(&font, 10, 25 * fy++, sstr.str().c_str());
|
||||
}
|
||||
|
||||
|
@ -214,6 +214,7 @@ player_t *Game::getFreePlayer() {
|
||||
if (player[i].status == 0)
|
||||
return &player[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
player_t *Game::spawnPlayer(Team *team) {
|
||||
|
Loading…
Reference in New Issue
Block a user