Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc @ 10718

Last change on this file since 10718 was 10718, checked in by rennerc, 17 years ago

dead gui :D

File size: 4.1 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer: Patrick Boenzli
15   co-programmer:
16
17
18   @todo: direction in which the projectile flights
19   @todo: a target to set/hit
20*/
21#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
22
23#include "world_entities/projectiles/projectile.h"
24
25#include "world_entity.h"
26#include "static_model.h"
27#include "weapon_manager.h"
28#include "util/loading/factory.h"
29#include "debug.h"
30
31
32#include "loading/fast_factory.h"
33
34#include "fps_sniper_rifle.h"
35
36
37#include "effects/explosion.h"
38
39
40
41
42
43ObjectListDefinition(FPSSniperRifle);
44CREATE_FACTORY(FPSSniperRifle);
45
46/**
47 *  standard constructor
48
49   creates a new weapon
50*/
51FPSSniperRifle::FPSSniperRifle ( int leftRight, OM_LIST list)
52  : Weapon()
53{
54  this->init(list);
55
56  this->leftRight = leftRight;
57}
58
59
60FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root)
61{
62  this->init( OM_GROUP_01 );
63
64  if (root != NULL)
65    this->loadParams(root);
66}
67
68/**
69 *  standard deconstructor
70*/
71FPSSniperRifle::~FPSSniperRifle ()
72{
73  // model will be deleted from WorldEntity-destructor
74  if( this->material != NULL)
75    delete this->material;
76}
77
78
79void FPSSniperRifle::init(OM_LIST list)
80{
81  this->registerObject(this, FPSSniperRifle::_objectList);
82
83  this->setAbsDir( this->getAbsDir() * Quaternion( -PI/2, Vector(1, 0, 0) ) );
84  this->loadModel("models/guns/fps_sniper_rifle.obj", 1.5);
85  this->material = new Material();
86  this->material->setIllum(3);
87  this->material->setAmbient(1.0, 1.0, 1.0);
88  this->material->setDiffuseMap("textures/fps_sniper_rifle.jpg");
89
90  this->setStateDuration(WS_SHOOTING, .1);
91  this->setStateDuration(WS_RELOADING, .1);
92  this->setStateDuration(WS_ACTIVATING, .4);
93  this->setStateDuration(WS_DEACTIVATING, .4);
94
95  this->setEnergyMax(100000);
96  this->increaseEnergy(100000);
97  //this->minCharge = 2;
98
99  //this->setActionSound(WA_SHOOT, "sounds/laser.wav");
100  //this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
101
102
103  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
104  //this->setProjectileTypeC("Laser");
105  //this->prepareProjectiles(20);
106  this->toList( list );
107  this->weapon = new BspWeapon( this->getOMListNumber() );
108  this->weapon->setAlwaysHits( true );
109  this->weapon->setDamage( 35 );
110  this->weapon->setParent( this );
111  this->weapon->toList( list );
112   
113  this->bFire = false;
114}
115
116
117void FPSSniperRifle::loadParams(const TiXmlElement* root)
118{
119  Weapon::loadParams(root);
120
121}
122
123
124/**
125 *  this activates the weapon
126
127   This is needed, since there can be more than one weapon on a ship. the
128   activation can be connected with an animation. for example the weapon is
129   been armed out.
130*/
131void FPSSniperRifle::activate()
132{
133}
134
135
136/**
137 *  this deactivates the weapon
138
139   This is needed, since there can be more than one weapon on a ship. the
140   activation can be connected with an animation. for example the weapon is
141   been armed out.
142*/
143void FPSSniperRifle::deactivate()
144{
145}
146
147
148/**
149 *  fires the weapon
150
151   this is called from the player.cc, when fire-button is been pushed
152   @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent
153*/
154void FPSSniperRifle::fire()
155{
156  this->bFire = true;
157}
158
159
160
161
162/**
163 *  this will draw the weapon
164 */
165void FPSSniperRifle::draw () const
166{
167  /* draw gun body */
168  glMatrixMode(GL_MODELVIEW);
169  glPushMatrix();
170
171  Vector pos = this->getAbsCoor() + this->getAbsDir().apply( Vector(3, -1.6622, -0.967) );
172  glTranslatef (pos.x,
173                pos.y,
174                pos.z);
175
176  Vector tmpRot = this->getAbsDir().getSpacialAxis();
177  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
178
179  if( this->leftRight == W_RIGHT)
180    glScalef(1.0, 1.0, -1.0);
181
182  this->material->select();
183  this->getModel()->draw();
184  //static_cast<StaticModel*>(this->getModel())->draw();
185
186  glPopMatrix();
187}
188
189void FPSSniperRifle::tick( float dt )
190{
191  Weapon::tick( dt );
192  this->weapon->fire( bFire );
193 
194  bFire = false;
195}
196
197
198
Note: See TracBrowser for help on using the repository browser.