switch to horde3d
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
include_directories (${GREMLIN_SOURCE_DIR}/src/common)
|
||||
include_directories (${CMAKE_SOURCE_DIR}/libs/horde3d-1.0.0-beta5/Include)
|
||||
|
||||
# define executable
|
||||
add_executable( gremlin
|
||||
@@ -6,14 +7,10 @@ add_executable( gremlin
|
||||
Explosion
|
||||
main
|
||||
oglfont
|
||||
Window
|
||||
Renderer
|
||||
)
|
||||
|
||||
add_dependencies( gremlin
|
||||
common
|
||||
glfw
|
||||
spark
|
||||
)
|
||||
|
||||
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 "Network.h"
|
||||
#include "Explosion.h"
|
||||
#include "Time.h"
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "Horde3D.h"
|
||||
|
||||
#include <GL/glfw.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -19,110 +14,9 @@
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
|
||||
GLUquadricObj *quadratic;
|
||||
namespace gln {
|
||||
|
||||
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() {
|
||||
|
||||
// Loads particle texture
|
||||
@@ -169,155 +63,6 @@ void setup_explosion() {
|
||||
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) {
|
||||
if (game.local_player == 0)
|
||||
return;
|
||||
@@ -365,44 +110,14 @@ void Client::loadConsoleFont() {
|
||||
oglf_load(&font, "data/fonts/console.fnt", font_id);
|
||||
}
|
||||
|
||||
void Client::prepareFrame(double rx, double ry, double rz) {
|
||||
// Get window size (may be different than the requested size)
|
||||
glfwGetWindowSize(&width, &height);
|
||||
height = height > 0 ? height : 1;
|
||||
void Client::initialize(Config &config) {
|
||||
Application::initialize(config);
|
||||
|
||||
// Set viewport
|
||||
glViewport(0, 0, width, height);
|
||||
window.initialize(config);
|
||||
renderer.initialize(&window, config);
|
||||
|
||||
// Clear color buffer
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
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);
|
||||
loadConsoleFont();
|
||||
//setup_explosion();
|
||||
|
||||
if (isMaster()) {
|
||||
Team *team = game.getTeam(0);
|
||||
@@ -425,12 +140,132 @@ void Client::initialize(Arguments &arg) {
|
||||
|
||||
// setup signals
|
||||
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() {
|
||||
|
||||
Application::update();
|
||||
|
||||
window.update();
|
||||
int x, y;
|
||||
glfwGetMousePos(&x, &y);
|
||||
if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_2) == GLFW_PRESS) {
|
||||
@@ -450,25 +285,7 @@ void Client::update() {
|
||||
|
||||
if (accelerate_schudule.next(time)) {
|
||||
double t = accelerate_schudule.getInterval();
|
||||
double v = 50.0 * 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
|
||||
processInput(t);
|
||||
}
|
||||
if (glfwGetKey(GLFW_KEY_LCTRL)) {
|
||||
if (time - last_bomb > 1.0) {
|
||||
@@ -477,18 +294,30 @@ void Client::update() {
|
||||
}
|
||||
}
|
||||
|
||||
btScalar bullet_trafo[16];
|
||||
if (game.local_player) {
|
||||
btVector3 p = game.local_player->body->getWorldTransform().getOrigin();
|
||||
|
||||
camX = p.x();
|
||||
camY = p.y();
|
||||
camZ = p.z();
|
||||
game.local_player->body->getWorldTransform().getOpenGLMatrix(
|
||||
bullet_trafo);
|
||||
// bullet_trafo[12] -= origin.x();
|
||||
// bullet_trafo[13] -= origin.y();
|
||||
// bullet_trafo[14] -= origin.z();
|
||||
} else {
|
||||
camX = 1000.0;
|
||||
camY = 1000.0;
|
||||
camZ = 1000.0;
|
||||
bullet_trafo[12] = 1000.0;
|
||||
bullet_trafo[13] = 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);
|
||||
setup_light();
|
||||
glEnable(GL_LIGHT0);
|
||||
@@ -499,10 +328,10 @@ void Client::update() {
|
||||
// draw_team(&game.teams[i]);
|
||||
|
||||
for (size_t i = 0; i < GAME_PLAYER_COUNT; i++)
|
||||
drawPlayer(&game.player[i]);
|
||||
drawPlayer(&game.player[i]);
|
||||
|
||||
for (size_t i = 0; i < GAME_BOMB_COUNT; i++)
|
||||
draw_bomb(&game.bomb[i]);
|
||||
draw_bomb(&game.bomb[i]);
|
||||
//
|
||||
// for (size_t i = 0; i < GAME_POINT_COUNT; i++)
|
||||
// draw_point(&game.point[i]);
|
||||
@@ -511,7 +340,7 @@ void Client::update() {
|
||||
|
||||
explosion.update(dt * 1000.0, camX, camY, camZ);
|
||||
explosion.render();
|
||||
|
||||
#endif
|
||||
glDisable(GL_LIGHT0);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_CULL_FACE);
|
||||
@@ -558,7 +387,6 @@ void Client::shutdown() {
|
||||
|
||||
Application::shutdown();
|
||||
|
||||
gluDeleteQuadric(quadratic);
|
||||
oglf_destroy(&font);
|
||||
glfwTerminate();
|
||||
}
|
||||
@@ -567,3 +395,4 @@ void Client::onExplosion(double x, double y, double z) {
|
||||
explosion.add(x, y, z);
|
||||
}
|
||||
|
||||
} // namespace grln
|
||||
|
@@ -10,14 +10,21 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "Schedule.h"
|
||||
#include "Renderer.h"
|
||||
#include "Window.h"
|
||||
|
||||
#include "oglfont.h"
|
||||
|
||||
namespace gln {
|
||||
|
||||
class Client: public Application {
|
||||
public:
|
||||
void initialize(Arguments &arg);
|
||||
void initialize(Config &config);
|
||||
void update();
|
||||
void shutdown();
|
||||
private:
|
||||
Window window;
|
||||
Renderer renderer;
|
||||
double last_bomb; //TODO: use bomb schedule;
|
||||
int last_x, last_y;
|
||||
double phi, theta;
|
||||
@@ -26,8 +33,7 @@ private:
|
||||
int width, height;
|
||||
//TrueTyeFont font;
|
||||
oglf_font_t font;
|
||||
|
||||
void prepareFrame(double rx, double ry, double rz);
|
||||
void processInput(double step);
|
||||
void accelerate(double x, double y, double z);
|
||||
void drop_bomb(double rx, double ry, double rz, double ttl);
|
||||
void loadConsoleFont();
|
||||
@@ -38,4 +44,6 @@ private:
|
||||
void drawPlayer(player_t *player);
|
||||
};
|
||||
|
||||
} // namespace grln
|
||||
|
||||
#endif /* CLIENT_H_ */
|
||||
|
@@ -1,15 +1,10 @@
|
||||
/*
|
||||
* Explosion.cpp
|
||||
*
|
||||
* Created on: 05.01.2011
|
||||
* Author: gmueller
|
||||
*/
|
||||
|
||||
#include "Explosion.h"
|
||||
|
||||
using namespace SPK;
|
||||
using namespace SPK::GL;
|
||||
|
||||
namespace gln {
|
||||
|
||||
Explosion::~Explosion() {
|
||||
SPKFactory::getInstance().destroyAll();
|
||||
}
|
||||
@@ -51,7 +46,7 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
||||
flashRenderer->setBlending(BLENDING_ADD);
|
||||
flashRenderer->enableRenderingHint(DEPTH_WRITE, false);
|
||||
flashRenderer->setShared(true);
|
||||
flashRenderer->setScale(scale,scale);
|
||||
flashRenderer->setScale(scale, scale);
|
||||
|
||||
// spark 1 renderer
|
||||
GLQuadRenderer* spark1Renderer = GLQuadRenderer::create();
|
||||
@@ -68,7 +63,7 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
||||
GLRenderer* spark2Renderer = NULL;
|
||||
if (GLPointRenderer::loadGLExtPointSprite()
|
||||
&& GLPointRenderer::loadGLExtPointParameter()) // uses point sprite if possible
|
||||
{
|
||||
{
|
||||
//GLPointRenderer::setPixelPerUnit(45.0f * PI / 180.f, scale * 1024);
|
||||
GLPointRenderer* pointRenderer = GLPointRenderer::create();
|
||||
pointRenderer->setType(POINT_SPRITE);
|
||||
@@ -82,7 +77,7 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
||||
quadRenderer->setTexturingMode(TEXTURE_2D);
|
||||
quadRenderer->setTexture(texturePoint);
|
||||
quadRenderer->setTextureBlending(GL_MODULATE);
|
||||
quadRenderer->setScale(0.02f * scale, 0.02f * scale);
|
||||
quadRenderer->setScale(0.02f * scale, 0.02f * scale);
|
||||
spark2Renderer = quadRenderer;
|
||||
}
|
||||
spark2Renderer->setBlending(BLENDING_ADD);
|
||||
@@ -111,9 +106,9 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
||||
Interpolator* interpolator = NULL; // pointer to an interpolator that is used to retrieve interpolators
|
||||
|
||||
// smoke model
|
||||
Model* smokeModel = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE
|
||||
| FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX,
|
||||
FLAG_SIZE | FLAG_ANGLE,
|
||||
Model* smokeModel = Model::create(
|
||||
FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA | FLAG_SIZE
|
||||
| FLAG_ANGLE | FLAG_TEXTURE_INDEX, FLAG_SIZE | FLAG_ANGLE,
|
||||
FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX, FLAG_ALPHA);
|
||||
smokeModel->setParam(PARAM_RED, 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);
|
||||
|
||||
// flame model
|
||||
Model* flameModel = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE
|
||||
| FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE | FLAG_TEXTURE_INDEX,
|
||||
FLAG_ANGLE | FLAG_RED | FLAG_GREEN | FLAG_BLUE, FLAG_ANGLE
|
||||
| FLAG_TEXTURE_INDEX, FLAG_SIZE | FLAG_ALPHA);
|
||||
Model* flameModel = Model::create(
|
||||
FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA | FLAG_SIZE
|
||||
| FLAG_ANGLE | FLAG_TEXTURE_INDEX,
|
||||
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_GREEN, 0.5f, 0.2f);
|
||||
flameModel->setParam(PARAM_BLUE, 0.2f, 0.2f);
|
||||
@@ -176,8 +172,9 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
||||
spark1Model->setShared(true);
|
||||
|
||||
// spark 2 model
|
||||
Model* spark2Model = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE
|
||||
| FLAG_ALPHA, FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA, FLAG_GREEN);
|
||||
Model* spark2Model = Model::create(
|
||||
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_RED, 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);
|
||||
|
||||
// wave model
|
||||
Model* waveModel = Model::create(FLAG_ALPHA | FLAG_SIZE, FLAG_SIZE
|
||||
| FLAG_ALPHA);
|
||||
Model* waveModel = Model::create(FLAG_ALPHA | FLAG_SIZE,
|
||||
FLAG_SIZE | FLAG_ALPHA);
|
||||
waveModel->setParam(PARAM_SIZE, 0.0f, 4.0f);
|
||||
waveModel->setParam(PARAM_ALPHA, 0.2f, 0.0f);
|
||||
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
|
||||
Sphere* explosionSphere = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f), 0.4f * scale);
|
||||
Sphere* explosionSphere2 = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f), 0.4f * 2.5* scale);
|
||||
Sphere* explosionSphere = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f),
|
||||
0.4f * scale);
|
||||
Sphere* explosionSphere2 = Sphere::create(Vector3D(0.0f, 0.0f, 0.0f),
|
||||
0.4f * 2.5 * scale);
|
||||
|
||||
// smoke emitter
|
||||
RandomEmitter* smokeEmitter = RandomEmitter::create();
|
||||
@@ -302,8 +301,8 @@ void Explosion::initialize(GLuint textureExplosion, GLuint textureFlash,
|
||||
void Explosion::render() {
|
||||
GLRenderer::saveGLStates();
|
||||
// Renders all the particle systems
|
||||
for (std::list<System*>::const_iterator it = particleSystems.begin(); it
|
||||
!= particleSystems.end(); ++it)
|
||||
for (std::list<System*>::const_iterator it = particleSystems.begin();
|
||||
it != particleSystems.end(); ++it)
|
||||
(*it)->render();
|
||||
GLRenderer::restoreGLStates();
|
||||
}
|
||||
@@ -349,3 +348,5 @@ void Explosion::update(double dt, double cx, double cy, double cz) {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace grln
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include "SPK.h"
|
||||
#include "SPK_GL.h"
|
||||
|
||||
namespace gln {
|
||||
|
||||
class Explosion {
|
||||
public:
|
||||
~Explosion();
|
||||
@@ -24,4 +26,6 @@ private:
|
||||
std::list<SPK::System*> particleSystems;
|
||||
};
|
||||
|
||||
} // namespace grln
|
||||
|
||||
#endif /* EXPLOSION_H_ */
|
||||
|
@@ -20,9 +20,11 @@ int main(int argc, const char **argv) {
|
||||
LOG4CPLUS_INFO(logger, " - " << argv[i]);
|
||||
|
||||
try {
|
||||
Client app;
|
||||
Arguments args(argc, argv);
|
||||
app.initialize(args);
|
||||
gln::Client app;
|
||||
gln::Config config;
|
||||
config.load(argc, argv);
|
||||
|
||||
app.initialize(config);
|
||||
while (app.isRunning())
|
||||
app.update();
|
||||
app.shutdown();
|
||||
|
Reference in New Issue
Block a user