home *** CD-ROM | disk | FTP | other *** search
- #include "Mech.h"
-
- #include "Game.h"
- #include "Renderer.h"
- #include "log.h"
-
- #include <math.h>
- #include "matrixmath.h"
-
- #define MECH_GROUND_CONTACT_STABLE 0.8f
-
-
- Mech::Mech(Client* client): Vehicle(client){
- groundContact = false;
- jumpjetsActive = false;
- jumpjetsEnergyConsumption = 20.0f;
-
- torsoModel = NULL;
- torsoAnimator = NULL;
- legsModel = NULL;
- legsAnimator = NULL;
-
- dlpcs.clear();
- legsModelSecondaryColors = NULL;
- torsoModelSecondaryColors = NULL;
- for(int i=0;i<4;i++){
- weaponModelSecondaryColors[i] = NULL;
- }
- }
-
- Mech::~Mech(){
- int i, j;
-
- if( legsModelSecondaryColors != NULL ){
- for(i=0;i<legsModel->numMeshes;i++){
- delete[] legsModelSecondaryColors[i];
- }
- delete[] legsModelSecondaryColors;
- }
- if( torsoModelSecondaryColors != NULL ){
- for(i=0;i<torsoModel->numMeshes;i++){
- delete[] torsoModelSecondaryColors[i];
- }
- delete[] torsoModelSecondaryColors;
- }
- for(i=0;i<4;i++){
- if( weaponModelSecondaryColors[i] != NULL ){
- for(j=0;j<weapons[i]->model->numMeshes;j++){
- delete[] weaponModelSecondaryColors[i][j];
- }
- delete[] weaponModelSecondaryColors[i];
- }
- }
-
- // if( torsoModel != NULL )
- // delete torsoModel;
- if( torsoAnimator != NULL )
- delete torsoAnimator;
- // if( legsModel != NULL )
- // delete legsModel;
- if( legsAnimator != NULL )
- delete legsAnimator;
-
- for(unsigned int k=0;k<dlpcs.size();k++){
- dlpcs[k].dlpc->vehicles.remove(this);
-
- if( legsModel != NULL ){
- for(j=0;j<legsModel->numMeshes;j++){
- delete[] dlpcs[k].legsModel_colors[j];
- }
- delete[] dlpcs[k].legsModel_colors;
- }
-
- if( torsoModel != NULL ){
- for(j=0;j<torsoModel->numMeshes;j++){
- delete[] dlpcs[k].torsoModel_colors[j];
- }
- delete[] dlpcs[k].torsoModel_colors;
- }
- }
- dlpcs.clear();
- }
-
-
- void Mech::moveForward(float deltaT){
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw)), 0.0f, (float)(sin(yaw)), tmp);
- vectorMA3d(vel_inp, deltaT*moveSpeed, tmp, vel_inp);
- }
- void Mech::moveBackward(float deltaT){
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw)), 0.0f, (float)(sin(yaw)), tmp);
- vectorMA3d(vel_inp, -deltaT*moveSpeed, tmp, vel_inp);
- }
- void Mech::moveLeft(float deltaT){
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw-PI*0.5f)), 0.0f, (float)(sin(yaw-PI*0.5f)), tmp);
- vectorMA3d(vel_inp, deltaT*moveSpeed, tmp, vel_inp);
- }
- void Mech::moveRight(float deltaT){
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw-PI*0.5f)), 0.0f, (float)(sin(yaw-PI*0.5f)), tmp);
- vectorMA3d(vel_inp, -deltaT*moveSpeed, tmp, vel_inp);
- }
- void Mech::moveUp(float deltaT){
- vectorMA3d(vel_inp, deltaT*moveSpeed, e2, vel_inp);
- }
- void Mech::moveDown(float deltaT){
- // vectorMA3d(vel_inp, -deltaT*moveSpeed, e2, vel_inp);
- }
-
-
-
- void Mech::move(){
- unsigned int currentMillis = SDL_GetTicks();
-
- if( lastMoveMillis >= currentMillis ) // sanity check
- return;
-
- float deltaT = (currentMillis - lastMoveMillis)/1000.0f;
- lastMoveMillis = currentMillis;
-
- reconstructVectors(); // make sure local COSystem is orthonormal
- anglesFromVectors();
-
- // calc recovery
- calcRecovery();
-
- // set animation
- if( legsAnimator != NULL ){
- if( vel_inp[0]*vel_inp[0] + vel_inp[2]*vel_inp[2] > 0.001f && vel_inp[1] <= 0.0f ){ // walking
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw)), 0.0f, (float)(sin(yaw)), tmp);
- if( vectorDotP3d(tmp, vel_inp) >= 0.0f ){ // walking forward
- legsAnimator->setPlayBackwards(false);
- }else{ // walking backwards
- legsAnimator->setPlayBackwards(true);
- }
- legsAnimator->start();
- }else{
- legsAnimator->pause();
- }
- }
-
- // jumpjets
- float energyCosts = deltaT * jumpjetsEnergyConsumption;
- if( vel_inp[1] > 0.001f && energy-energyCosts > 0.0f){
- jumpjetsActive = true;
- energy -= energyCosts;
- }else{
- jumpjetsActive = false;
- }
-
-
- float groundContactRatio = calcGroundContactRatio();
- groundContact = groundContactRatio > 0.0f;
-
- if( groundContactRatio > 1.0f ){ // stuck in ground -> add a slight upward movement to correct this
- // vectorMA3d(vel, 20.0f*deltaT, e2, vel);
- vec3_t correctingDisplacement;
- vectorScale3d(0.01f, e2, correctingDisplacement);
- if( collisionDetection(correctingDisplacement) ){ // check if move is save
- vectorAdd3d(pos, correctingDisplacement, pos); // ...and move
- }
- }
-
- // do physics
- if( groundContactRatio > MECH_GROUND_CONTACT_STABLE && !jumpjetsActive ){ // standing stable
-
- vectorInit3d(0.0f, 0.0f, 0.0f, vel); // to avoid problems with slow clients (�erschwinger)
- vectorCopy3d(vel, physicsInfo.v);
- vectorInit3d(0.0f, 0.0f, 0.0f, physicsInfo.F_i);
- //physicsInfo.r = 6000.0f;
- physicsInfo.r = 0.0f;
- physicsInfo.g = 0.0f;
- physicsInfo.calcAcceleration();
-
- vectorMA3d(vel, moveSpeed, vel_inp, vel);
- vectorMA3d(vel, deltaT, physicsInfo.a, vel);
- // printf("vi: %f %f %f\n", vel_inp[0], vel_inp[1], vel_inp[2]);
- // printf("v: %f %f %f\n", vel[0], vel[1], vel[2]);
-
- // printf("STANDING\n");
- }else{ // falling, flying, standing on edge, ...
-
- vec3_t tmp;
- vectorCopy3d(vel_inp, tmp);
- if( jumpjetsActive ){
- tmp[1] = 4.5f;
- }else{
- tmp[1] = -0.6f*Game::arena->gravity;
- }
- vectorScale3d(600.0f, tmp, physicsInfo.F_i);
- vectorCopy3d(vel, physicsInfo.v);
- physicsInfo.r = 50.0f;
- physicsInfo.g = Game::arena->gravity;
- physicsInfo.calcAcceleration();
- vectorMA3d(vel, deltaT, physicsInfo.a, vel);
- // printf("FALLING\n");
- }
- vec3_t tmp;
- vectorInit3d(vel[0], 0.0f, vel[2], tmp);
- if( vectorLength3d(tmp) > moveSpeed ){
- vectorNormalize3d(tmp, tmp);
- vectorScale3d(moveSpeed, tmp, tmp);
- vel[0] = tmp[0];
- vel[2] = tmp[2];
- }
-
- vec3_t displacement;
- vectorScale3d(deltaT, vel, displacement);
-
- if( collisionDetection(displacement) ){ // check if move is save
- vectorAdd3d(pos, displacement, pos); // ...and move
- }
-
- vectorScale3d(1.0f/deltaT, displacement, vel);
- }
-
-
- float Mech::calcGroundContactRatio(){
- vec3_t testPos, normal;
- trace_t trace;
- trace.ignoreFlags = 0 | COLLISION_FLAG_BACKFACES | COLLISION_FLAG_WALK_THROUGH;
- float ret = -1.0f;
-
- AABB_t testAABB;
- vectorInit3d(moveAABB.max[0], moveAABB.min[1]+0.15f, moveAABB.max[2], testAABB.max);
- vectorInit3d(moveAABB.min[0], moveAABB.min[1], moveAABB.min[2], testAABB.min);
-
- // move into ground to check if we have ground contact
- vectorMA3d(pos, -0.15f, e2, testPos);
-
- traceAABB(pos, testPos, testAABB, &trace);
- for(unsigned int i=0;i<trace.hits.size();i++){
- if( trace.hits[i].face != NULL ){
- vectorCopy3d(trace.hits[i].face->normal, normal);
- }
-
- if( trace.hits[i].vehicle != NULL ){ // hit a vehicle
- if( trace.hits[i].vehicle == this )
- continue;
-
- vectorSub3d(this->pos, trace.hits[i].vehicle->pos, normal);
- vectorNormalize3d(normal, normal);
- }
-
- float dp = vectorDotP3d(normal, e2);
- ret = dp > ret ? dp : ret;
- }
-
- // check if we have TOO MUCH ground contact (i.e. stuck in ground)
- if( ret > MECH_GROUND_CONTACT_STABLE ){
- vectorMA3d(pos, -0.10f, e2, testPos);
-
- traceAABB(pos, testPos, testAABB, &trace);
- if( trace.hits.size() > 1 ){ // do NOT count self as hit...
- ret = 2.0f;
- // printf("STUCK IN GROUND!\n");
- }
- }
-
- return ret;
- }
-
-
-
-
-
- void Mech::addDynamicLightParticleCluster(DynamicLightParticleCluster* dlpc){
- int i, j, k;
- mech_dlpcCombo_t c;
-
- c.dlpc = dlpc;
-
- // LEGS
- if( legsModel != NULL ){
- int frame = (int)legsAnimator->getCurrentFrame();
- // printf("frame: %i\n", frame);
-
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw)), 0.0f, (float)(sin(yaw)), tmp);
- float m[] = { left[0], left[1], left[2], 0.0f,
- e2[0], e2[1], e2[2], 0.0f,
- tmp[0], tmp[1], tmp[2], 0.0f,
- pos[0], pos[1], pos[2], 1.0f
- };
-
- float im[16];
- float cm[16];
- vec4_t transformedPos;
-
- c.legsModel_colors = new GLfloat*[legsModel->numMeshes];
- for(i=0;i<legsModel->numMeshes;i++){
- Mesh* mesh = legsModel->meshes[i];
- c.legsModel_colors[i] = new GLfloat[mesh->numVertices*3];
-
- matrixMultMatrix(m, legsModel->matrices[frame][i], 4, cm);
- matrixInvert(cm, 4, im);
- vectorInit4d(dlpc->pos[0], dlpc->pos[1], dlpc->pos[2], 1.0f, transformedPos);
- matrixMultVector(im, transformedPos, 4, transformedPos);
- float transformedRadius = dlpc->radius;// * (float)(fabs(im[0]);
-
- for(j=0;j<mesh->numVertices;j++){
- float f = vectorPointDistance3d(transformedPos, &mesh->vertices[j*3]) / transformedRadius;
- if( f < 0.0f ){ // most likely matrix was not inverted correctly...
- // printf("LEGS: f: %f; tr: %f\n", f, transformedRadius);
- f = 0.0f;
- }
- if( f > 1.0f ){
- // printf("LEGS: f: %f; tr: %f\n", f, transformedRadius);
- f = 1.0f;
- }
- //f = f > 1.0f ? 1.0f : f;
- vectorScale3d(1.0f - f, dlpc->col, &c.legsModel_colors[i][j*3]);
- vectorAdd3d(&legsModelSecondaryColors[i][j*3], &c.legsModel_colors[i][j*3], &legsModelSecondaryColors[i][j*3]);
- }
- }
- }
-
- // TORSO
- if( torsoModel != NULL ){
- int frame = 0;//(int)legsAnimator->getCurrentFrame();
- // printf("frame: %i\n", frame);
-
- // vec3_t tmp;
- // vectorInit3d((float)(cos(yaw)), 0.0f, (float)(sin(yaw)), tmp);
- float m[] = { left[0], left[1], left[2], 0.0f,
- up[0], up[1], up[2], 0.0f,
- dir[0], dir[1], dir[2], 0.0f,
- pos[0], pos[1], pos[2], 1.0f
- };
-
- float im[16];
- float cm[16];
- vec4_t transformedPos;
-
- c.torsoModel_colors = new GLfloat*[torsoModel->numMeshes];
- for(i=0;i<torsoModel->numMeshes;i++){
- Mesh* mesh = torsoModel->meshes[i];
- c.torsoModel_colors[i] = new GLfloat[mesh->numVertices*3];
-
- matrixMultMatrix(m, torsoModel->matrices[frame][i], 4, cm);
- matrixInvert(cm, 4, im);
- vectorInit4d(dlpc->pos[0], dlpc->pos[1], dlpc->pos[2], 1.0f, transformedPos);
- matrixMultVector(im, transformedPos, 4, transformedPos);
- float transformedRadius = dlpc->radius;// * (float)fabs(im[0]);
-
- for(j=0;j<mesh->numVertices;j++){
- float f = vectorPointDistance3d(transformedPos, &mesh->vertices[j*3]) / transformedRadius;
- if( f < 0.0f ){ // most likely matrix was not inverted correctly...
- // printf("TORSO: f: %f; tr: %f\n", f, transformedRadius);
- f = 0.0f;
- }
- if( f > 1.0f ){
- // printf("TORSO: f: %f; tr: %f\n", f, transformedRadius);
- f = 1.0f;
- }
- // f = f > 1.0f ? 1.0f : f;
- vectorScale3d(1.0f - f, dlpc->col, &c.torsoModel_colors[i][j*3]);
- vectorAdd3d(&torsoModelSecondaryColors[i][j*3], &c.torsoModel_colors[i][j*3], &torsoModelSecondaryColors[i][j*3]);
- }
- }
- }
-
- // WEAPONS
- for(k=0;k<4;k++){
- if( weapons[k] != NULL ){
- int frame = 0;
- float m[] = { left[0], left[1], left[2], 0.0f,
- up[0], up[1], up[2], 0.0f,
- dir[0], dir[1], dir[2], 0.0f,
- pos[0], pos[1], pos[2], 1.0f
- };
-
- float transM[] = { 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- weapons[k]->mountPoint[0], weapons[k]->mountPoint[1], weapons[k]->mountPoint[2], 1.0f
- };
-
- float im[16];
- float cm[16];
- vec4_t transformedPos;
-
- c.weaponModel_colors[k] = new GLfloat*[weapons[k]->model->numMeshes];
- for(i=0;i<weapons[k]->model->numMeshes;i++){
- Mesh* mesh = weapons[k]->model->meshes[i];
- c.weaponModel_colors[k][i] = new GLfloat[mesh->numVertices*3];
-
- matrixMultMatrix(m, transM, 4, cm);
- matrixMultMatrix(cm, weapons[k]->model->matrices[frame][i], 4, cm);
- matrixInvert(cm, 4, im);
- vectorInit4d(dlpc->pos[0], dlpc->pos[1], dlpc->pos[2], 1.0f, transformedPos);
- matrixMultVector(im, transformedPos, 4, transformedPos);
- float transformedRadius = dlpc->radius;// * (float)fabs(im[0]);
-
- for(j=0;j<mesh->numVertices;j++){
- float f = vectorPointDistance3d(transformedPos, &mesh->vertices[j*3]) / transformedRadius;
- if( f < 0.0f ){ // most likely matrix was not inverted correctly...
- f = 0.0f;
- }
- if( f > 1.0f ){
- f = 1.0f;
- }
- vectorScale3d(1.0f - f, dlpc->col, &c.weaponModel_colors[k][i][j*3]);
- vectorAdd3d(&weaponModelSecondaryColors[k][i][j*3], &c.weaponModel_colors[k][i][j*3], &weaponModelSecondaryColors[k][i][j*3]);
- }
- }
- }
- }
-
- dlpcs.push_back(c);
- // printf("dlpc added!\n");
- }
- void Mech::removeDynamicLightParticleCluster(DynamicLightParticleCluster* dlpc){
- int i,j;
-
- for( vector<mech_dlpcCombo_t>::iterator iter = dlpcs.begin(); iter != dlpcs.end(); iter++ ){
- if( iter->dlpc == dlpc ){
- if( legsModel != NULL ){
- for(i=0;i<legsModel->numMeshes;i++){
- Mesh* m = legsModel->meshes[i];
- for(j=0;j<m->numVertices;j++){
- vectorSub3d(&legsModelSecondaryColors[i][j*3], &iter->legsModel_colors[i][j*3], &legsModelSecondaryColors[i][j*3]);
- }
- delete[] iter->legsModel_colors[i];
- }
- delete[] iter->legsModel_colors;
- }
-
- if( torsoModel != NULL ){
- for(i=0;i<torsoModel->numMeshes;i++){
- Mesh* m = torsoModel->meshes[i];
- for(j=0;j<m->numVertices;j++){
- vectorSub3d(&torsoModelSecondaryColors[i][j*3], &iter->torsoModel_colors[i][j*3], &torsoModelSecondaryColors[i][j*3]);
- }
- delete[] iter->torsoModel_colors[i];
- }
- delete[] iter->torsoModel_colors;
- }
-
- for(int k=0;k<4;k++){
- if( weapons[k] != NULL ){
- for(i=0;i<weapons[k]->model->numMeshes;i++){
- Mesh* m = weapons[k]->model->meshes[i];
- for(j=0;j<m->numVertices;j++){
- vectorSub3d(&weaponModelSecondaryColors[k][i][j*3], &iter->weaponModel_colors[k][i][j*3], &weaponModelSecondaryColors[k][i][j*3]);
- }
- delete[] iter->weaponModel_colors[k][i];
- }
- delete[] iter->weaponModel_colors[k];
- }
- }
-
- dlpcs.erase(iter);
- break;
- }
- }
-
- // printf("dlpc removed!\n");
- }
-
-
-
- void Mech::render(){
- int i, j, k;
-
- int lm_sav = Renderer::info.var.lightingMode;
-
- // calc the shading color
- if( Renderer::info.var.shadeVehicles &&
- (Renderer::info.var.lightingMode == LIGHTING_MODE_VERTEX || Renderer::info.var.lightingMode == LIGHTING_MODE_LIGHTMAP) ){
-
- Renderer::info.var.lightingMode = LIGHTING_MODE_VERTEX; // set to vertex lighting because we need vertex colors
-
- vec3_t col, absMin, absMax;
- vectorInit3d(0.0f, 0.0f, 0.0f, col);
- float w_sum = 0.0f;
- float maxDistance = 7.0f;
-
- vectorInit3d(pos[0]-maxDistance, pos[1]-maxDistance, pos[2]-maxDistance, absMin);
- vectorInit3d(pos[0]+maxDistance, pos[1]+maxDistance, pos[2]+maxDistance, absMax);
- vector<SpacePartitioningTreeNode*> nodes = Game::arena->sptree->getLeafNodesIntersectingAABB(absMin, absMax);
-
- for(i=0;i<(signed int)nodes.size();i++){
- // nodes[i]->drawBorders();
- Mesh* m = nodes[i]->mesh;
- if( m != NULL ){
-
- for(j=0;j<m->numVertices;j++){
- float d = vectorPointDistance3d(pos, &m->vertices[j*3]);
- // vec3_t tmp;
- // vectorSub3d(&m->vertices[j*3], pos, tmp);
- // float d = vectorLength3d(tmp);
- if( d < maxDistance /*&& vectorDotP3d(tmp, &m->normals[j*3]) < 0.0f*/ ){
- float w = 1.0f - d/maxDistance;
- w_sum += w;
- vectorMA3d(col, w, &m->colors[j*3], col);
- // Renderer::debug_renderLinesegment(pos, &m->vertices[j*3]);
- }
- }
-
- // if( nearestIndex != -1 ){
- // vectorCopy3d(&m->colors[nearestIndex*3], col);
- // Renderer::debug_renderLinesegment(pos, &m->vertices[nearestIndex*3]);
- // }
- }
- }
-
- if( w_sum > 0.0f ){ // assign new colors
- vectorScale3d(1.0f/w_sum, col, col);
-
- if( torsoModel != NULL ){
- for(i=0;i<torsoModel->numMeshes;i++){
- for(j=0;j<torsoModel->meshes[i]->numColors;j++){
- vectorCopy3d(col, &torsoModel->meshes[i]->colors[j*3]);
- }
- }
- }
- if( legsModel != NULL ){
- for(i=0;i<legsModel->numMeshes;i++){
- for(j=0;j<legsModel->meshes[i]->numColors;j++){
- vectorCopy3d(col, &legsModel->meshes[i]->colors[j*3]);
- }
- }
- }
- for(k=0;k<4;k++){
- if( weapons[k] == NULL )
- continue;
-
- for(i=0;i<weapons[k]->model->numMeshes;i++){
- for(j=0;j<weapons[k]->model->meshes[i]->numColors;j++){
- vectorCopy3d(col, &weapons[k]->model->meshes[i]->colors[j*3]);
- }
- }
- }
- }else{ // keep old colors
- }
-
- }
-
- // legs
- if( legsModel != NULL ){
-
- if( Renderer::info.var.useDynamicLighting && legsModelSecondaryColors != NULL ){ // setup dyn lighting
- for(i=0;i<legsModel->numMeshes;i++){
- legsModel->meshes[i]->secondaryColors = legsModelSecondaryColors[i];
- }
-
- }
-
- glPushMatrix();
-
- vec3_t tmp;
- vectorInit3d((float)(cos(yaw)), 0.0f, (float)(sin(yaw)), tmp);
- float m[] = { left[0], left[1], left[2], 0.0f,
- e2[0], e2[1], e2[2], 0.0f,
- tmp[0], tmp[1], tmp[2], 0.0f,
- pos[0], pos[1], pos[2], 1.0f
- };
- glMultMatrixf(m);
-
- float frame = 0.0f;
- if( legsAnimator != NULL ){
- frame = legsAnimator->calcCurrentFrame();
- }
- Renderer::renderModel(legsModel, frame);
-
- glPopMatrix();
-
- if( Renderer::info.var.useDynamicLighting && legsModelSecondaryColors != NULL ){
- for(i=0;i<legsModel->numMeshes;i++){
- legsModel->meshes[i]->secondaryColors = NULL;
- }
- }
- }
-
-
- // torso
- if( torsoModel != NULL &&
- !(Game::cam.mode == CAMERA_MODE_FIRST_PERSON && Game::cam.target == this) ){
-
- if( Renderer::info.var.useDynamicLighting && torsoModelSecondaryColors != NULL ){ // setup dyn lighting
- for(i=0;i<torsoModel->numMeshes;i++){
- torsoModel->meshes[i]->secondaryColors = torsoModelSecondaryColors[i];
- }
- }
-
-
-
- glPushMatrix();
- float m[] = { left[0], left[1], left[2], 0.0f,
- up[0], up[1], up[2], 0.0f,
- dir[0], dir[1], dir[2], 0.0f,
- pos[0], pos[1], pos[2], 1.0f
- };
- glMultMatrixf(m);
- Renderer::renderModel(torsoModel);
-
- glPopMatrix();
-
- if( Renderer::info.var.useDynamicLighting && torsoModelSecondaryColors != NULL ){
- for(i=0;i<torsoModel->numMeshes;i++){
- torsoModel->meshes[i]->secondaryColors = NULL;
- }
- }
-
- }
-
- // weapons
- for( k=0; k<4; k++ ){
- if( weapons[k] == NULL )
- continue;
-
- if( Renderer::info.var.useDynamicLighting && weaponModelSecondaryColors[k] != NULL ){ // setup dyn lighting
- for(i=0;i<weapons[k]->model->numMeshes;i++){
- weapons[k]->model->meshes[i]->secondaryColors = weaponModelSecondaryColors[k][i];
- }
- }
-
- glPushMatrix();
- float m[] = { left[0], left[1], left[2], 0.0f,
- up[0], up[1], up[2], 0.0f,
- dir[0], dir[1], dir[2], 0.0f,
- pos[0], pos[1], pos[2], 1.0f
- };
- glMultMatrixf(m);
-
- glTranslatef(weapons[k]->mountPoint[0], weapons[k]->mountPoint[1], weapons[k]->mountPoint[2]);
-
- float frame = 0.0f;
- if( weapons[k]->animator != NULL ){ // setup animation
- frame = weapons[k]->animator->calcCurrentFrame();
- // printf("frame: %f\n", frame);
- }
- Renderer::renderModel(weapons[k]->model, frame);
-
- glPopMatrix();
-
- if( Renderer::info.var.useDynamicLighting && weaponModelSecondaryColors[k] != NULL ){
- for(i=0;i<weapons[k]->model->numMeshes;i++){
- weapons[k]->model->meshes[i]->secondaryColors = NULL;
- }
- }
- }
-
- if( Renderer::info.var.shadeVehicles &&
- (Renderer::info.var.lightingMode == LIGHTING_MODE_VERTEX || Renderer::info.var.lightingMode == LIGHTING_MODE_LIGHTMAP) ){
-
- Renderer::info.var.lightingMode = lm_sav; // restore lm if we did vehcile shading
- }
-
- Vehicle::render();
-
- }
-