Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/space_ships/space_ship.cc @ 6779

Last change on this file since 6779 was 6764, checked in by bensch, 19 years ago

trunk: better lighting

File size: 19.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Benjamin Knecht
13   co-programmer: Silvan Nellen
14
15*/
16
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
19#include "executor/executor.h"
20#include "space_ship.h"
21
22#include "objModel.h"
23#include "resource_manager.h"
24
25#include "weapons/weapon_manager.h"
26#include "weapons/test_gun.h"
27#include "weapons/turret.h"
28#include "weapons/cannon.h"
29
30#include "particle_emitter.h"
31#include "sprite_particles.h"
32
33#include "factory.h"
34#include "key_mapper.h"
35#include "event_handler.h"
36
37#include "network_game_manager.h"
38
39#include "power_ups/weapon_power_up.h"
40#include "power_ups/param_power_up.h"
41
42#include "graphics_engine.h"
43
44#include "plane.h"
45
46#include "state.h"
47#include "player.h"
48
49
50// #include "lib/gui/gl_gui/glgui_bar.h"
51// #include "lib/gui/gl_gui/glgui_pushbutton.h"
52
53
54using namespace std;
55
56CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP);
57
58/**
59 *  creates the controlable Spaceship
60 */
61SpaceShip::SpaceShip()
62{
63  this->init();
64}
65
66/**
67 *  destructs the spaceship, deletes alocated memory
68 */
69SpaceShip::~SpaceShip ()
70{
71}
72
73/**
74 * loads a Spaceships information from a specified file.
75 * @param fileName the name of the File to load the spaceship from (absolute path)
76 */
77SpaceShip::SpaceShip(const char* fileName)
78{
79  this->init();
80  TiXmlDocument doc(fileName);
81
82  if(!doc.LoadFile())
83  {
84    PRINTF(2)("Loading file %s failed for spaceship.\n", fileName);
85    return;
86  }
87
88  this->loadParams(doc.RootElement());
89}
90
91/**
92 *  creates a new Spaceship from Xml Data
93 * @param root the xml element containing spaceship data
94
95   @todo add more parameters to load
96*/
97SpaceShip::SpaceShip(const TiXmlElement* root)
98{
99  this->init();
100  if (root != NULL)
101    this->loadParams(root);
102  else
103  {
104    this->loadModel("models/ships/reap_#.obj");
105  }
106
107}
108
109
110/**
111 * initializes a Spaceship
112 */
113void SpaceShip::init()
114{
115//  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
116  this->setClassID(CL_SPACE_SHIP, "SpaceShip");
117
118  PRINTF(4)("SPACESHIP INIT\n");
119
120  //weapons:
121  Weapon* wpRight = new TestGun(0);
122  wpRight->setName("testGun Right");
123  Weapon* wpLeft = new TestGun(1);
124  wpLeft->setName("testGun Left");
125  Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_CANNON));
126
127  cannon->setName("BFG");
128
129  this->addWeapon(wpLeft, 1, 0);
130  this->addWeapon(wpRight,1 ,1);
131  this->addWeapon(cannon, 0, 6);
132
133  this->getWeaponManager()->changeWeaponConfig(1);
134
135  EventHandler::getInstance()->grabEvents(true);
136
137  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
138  bFire = false;
139  xMouse = yMouse = 0;
140  yInvert = 1;
141  mouseSensitivity = 0.001;
142  airViscosity = 0.05;
143  controlVelocityX = 25;
144  controlVelocityY = 150;
145  shipInertia = 1.5             ;
146//  cycle = 0.0;
147
148  this->setHealthMax(100);
149  this->setHealth(80);
150
151  travelSpeed = 40.0;
152  acceleration = 3;
153  this->velocity = this->getAbsDirX()*travelSpeed;
154  this->mouseDir = this->getAbsDir();
155  this->pitchDir = this->getAbsDir();
156
157//   GLGuiButton* button = new GLGuiPushButton();
158//    button->show();
159//    button->setLabel("orxonox");
160//    button->setBindNode(this);
161//     GLGuiBar* bar = new GLGuiBar();
162//     bar->show();
163//     bar->setValue(7.0);
164//     bar->setMaximum(10);
165//     bar->setSize2D( 20, 100);
166//     bar->setAbsCoor2D( 10, 200);
167
168  //add events to the eventlist
169  registerEvent(KeyMapper::PEV_UP);
170  registerEvent(KeyMapper::PEV_DOWN);
171  registerEvent(KeyMapper::PEV_LEFT);
172  registerEvent(KeyMapper::PEV_RIGHT);
173  //registerEvent(SDLK_q);
174  //registerEvent(SDLK_e);
175  registerEvent(KeyMapper::PEV_FIRE1);
176  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
177  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
178  //registerEvent(SDLK_PAGEUP);
179  //registerEvent(SDLK_PAGEDOWN);
180  registerEvent(EV_MOUSE_MOTION);
181
182  this->getWeaponManager()->setSlotCount(7);
183
184  this->getWeaponManager()->setSlotPosition(0, Vector(-2.6, .1, -3.0));
185  this->getWeaponManager()->setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
186
187  this->getWeaponManager()->setSlotPosition(1, Vector(-2.6, .1, 3.0));
188  this->getWeaponManager()->setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
189
190  this->getWeaponManager()->setSlotPosition(2, Vector(-1.5, .5, -.5));
191  this->getWeaponManager()->setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
192
193  this->getWeaponManager()->setSlotPosition(3, Vector(-1.5, .5, .5));
194  this->getWeaponManager()->setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
195
196  this->getWeaponManager()->setSlotPosition(4, Vector(-1.5, -.5, .5));
197  this->getWeaponManager()->setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
198
199  this->getWeaponManager()->setSlotPosition(5, Vector(-1.5, -.5, -.5));
200  this->getWeaponManager()->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
201//
202   this->getWeaponManager()->setSlotPosition(6, Vector(-1, 0.0, 0));
203   this->getWeaponManager()->setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
204   //
205//   this->getWeaponManager()->setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
206//   this->getWeaponManager()->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
207//
208//   this->getWeaponManager()->setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
209//   this->getWeaponManager()->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
210
211  this->getWeaponManager()->getFixedTarget()->setParent(this);
212  this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0);
213
214  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
215
216  this->burstEmitter = new ParticleEmitter(Vector(1,0,0), .01, 200, 0.0);
217  this->burstEmitter->setParent(this);
218  this->burstEmitter->setRelCoor(-1, .5, 0);
219  this->burstEmitter->setName("SpaceShip_Burst_emitter");
220
221  this->burstSystem = new SpriteParticles(1000);
222  this->burstSystem->addEmitter(this->burstEmitter);
223  this->burstSystem->setName("SpaceShip_Burst_System");
224  ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png");
225  this->burstSystem->setLifeSpan(1.0, .3);
226  this->burstSystem->setRadius(0.0, 1.0);
227  this->burstSystem->setRadius(0.05, 1.0);
228  this->burstSystem->setRadius(.5, .8);
229  this->burstSystem->setRadius(1.0, 0);
230  this->burstSystem->setColor(0.0, .7,.7,1,.7);
231  this->burstSystem->setColor(0.2, 0,0,0.8,.5);
232  this->burstSystem->setColor(0.5, .5,.5,.8,.8);
233  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
234
235}
236
237
238/**
239 * loads the Settings of a SpaceShip from an XML-element.
240 * @param root the XML-element to load the Spaceship's properties from
241 */
242void SpaceShip::loadParams(const TiXmlElement* root)
243{
244  Playable::loadParams(root);
245}
246
247
248void SpaceShip::enter()
249{
250  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
251  this->attachCamera();
252}
253
254void SpaceShip::leave()
255{
256  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
257  this->detachCamera();
258}
259
260
261/**
262 *  effect that occurs after the SpaceShip is spawned
263*/
264void SpaceShip::postSpawn ()
265{
266  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
267}
268
269/**
270 *  the action occuring if the spaceship left the game
271*/
272void SpaceShip::leftWorld ()
273{}
274
275WorldEntity* ref = NULL;
276/**
277 *  this function is called, when two entities collide
278 * @param entity: the world entity with whom it collides
279 *
280 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
281 */
282void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
283{
284  Playable::collidesWith(entity, location);
285  if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)
286  {
287    this->ADDWEAPON();
288    ref = entity;
289    }
290//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
291}
292
293/**
294 *  draws the spaceship after transforming it.
295*/
296void SpaceShip::draw () const
297{
298  WorldEntity::draw();
299  this->getWeaponManager()->draw();
300
301  //this->debug(0);
302}
303
304/**
305 *  the function called for each passing timeSnap
306 * @param time The timespan passed since last update
307*/
308void SpaceShip::tick (float time)
309{
310  this->getWeaponManager()->tick(time);
311  // weapon system manipulation
312  this->weaponAction();
313
314  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )
315   {
316    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
317    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
318    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
319    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
320
321    pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
322
323    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
324    xMouse = yMouse = 0;
325   }
326
327
328//   if( this != State::getPlayer()->getControllable())
329//     return;
330
331  // spaceship controlled movement
332  this->calculateVelocity(time);
333
334  Vector move = velocity*time;
335
336  //orient the velocity in the direction of the spaceship.
337  travelSpeed = velocity.len();
338  velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
339  velocity = (velocity.getNormalized())*travelSpeed;
340  this->burstEmitter->setEmissionRate(travelSpeed);
341  this->burstEmitter->setEmissionVelocity(travelSpeed*.5, travelSpeed *.1);
342
343  //orient the spaceship in direction of the mouse
344   rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
345   if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
346    this->setAbsDir( rotQuat);
347   //this->setAbsDirSoft(mouseDir,5);
348
349  // this is the air friction (necessary for a smooth control)
350  if(travelSpeed >= 120) velocity -= velocity.getNormalized()*travelSpeed*travelSpeed*0.0001;
351  else if (travelSpeed <= 80) velocity -= velocity.getNormalized()*travelSpeed*0.001;
352
353  //other physics (gravity)
354  //if(travelSpeed < 120)
355  //move += Vector(0,-1,0)*60*time + Vector(0,1,0)*travelSpeed/2*time;
356
357  //hoover effect
358  //cycle += time;
359  //this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
360
361  //readjust
362  //if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
363  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
364
365  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
366
367  this->shiftCoor(move);
368
369
370}
371
372/**
373 *  calculate the velocity
374 * @param time the timeslice since the last frame
375*/
376void SpaceShip::calculateVelocity (float time)
377{
378  Vector accel(0.0, 0.0, 0.0);
379  /*
380  Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter
381  */
382  //float rotVal = 0.0;
383  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
384  /* calculate the direction in which the craft is heading  */
385
386  //Plane plane(Vector(0,1,0), Vector(0,0,0));
387
388  if( this->bUp )
389   {
390     //this->shiftCoor(this->getAbsDirX());
391      //accel += (this->getAbsDirX())*2;
392      accel += (this->getAbsDirX())*acceleration;
393
394   }
395
396  if( this->bDown )
397   {
398     //this->shiftCoor((this->getAbsDirX())*-1);
399     //accel -= (this->getAbsDirX())*2;
400    //if(velocity.len() > 50)
401     accel -= (this->getAbsDirX())*0.5*acceleration;
402
403
404
405   }
406
407  if( this->bLeft/* > -this->getRelCoor().z*2*/)
408  {
409    this->shiftDir(Quaternion(time, Vector(0,1,0)));
410//    accel -= rightDirection;
411    //velocityDir.normalize();
412    //rot +=Vector(1,0,0);
413    //rotVal -= .4;
414  }
415  if( this->bRight /* > this->getRelCoor().z*2*/)
416  {
417    this->shiftDir(Quaternion(-time, Vector(0,1,0)));
418
419    //    accel += rightDirection;
420    //velocityDir.normalize();
421    //rot += Vector(1,0,0);
422    //rotVal += .4;
423  }
424
425
426  if( this->bRollL /* > -this->getRelCoor().z*2*/)
427  {
428    mouseDir *= Quaternion(-time*2, Vector(1,0,0));
429//    accel -= rightDirection;
430    //velocityDir.normalize();
431    //rot +=Vector(1,0,0);
432    //rotVal -= .4;
433  }
434  if( this->bRollR /* > this->getRelCoor().z*2*/)
435  {
436    mouseDir *= Quaternion(time*2, Vector(1,0,0));
437
438    //    accel += rightDirection;
439    //velocityDir.normalize();
440    //rot += Vector(1,0,0);
441    //rotVal += .4;
442  }
443  if (this->bAscend )
444  {
445    this->shiftDir(Quaternion(time, Vector(0,0,1)));
446
447//    accel += upDirection;
448    //velocityDir.normalize();
449    //rot += Vector(0,0,1);
450    //rotVal += .4;
451  }
452  if (this->bDescend )
453  {
454    this->shiftDir(Quaternion(-time, Vector(0,0,1)));
455
456    //    accel -= upDirection;
457    //velocityDir.normalize();
458    //rot += Vector(0,0,1);
459    //rotVal -= .4;
460  }
461
462  velocity += accel;
463  //rot.normalize();
464  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
465}
466
467/**
468 * weapon manipulation by the player
469*/
470void SpaceShip::weaponAction()
471{
472  if( this->bFire)
473    {
474      this->getWeaponManager()->fire();
475    }
476}
477
478/**
479 * @todo switch statement ??
480 */
481void SpaceShip::process(const Event &event)
482{
483  if( event.type == KeyMapper::PEV_LEFT)
484      this->bRollL = event.bPressed;
485  else if( event.type == KeyMapper::PEV_RIGHT)
486      this->bRollR = event.bPressed;
487  else if( event.type == KeyMapper::PEV_FIRE1)
488      this->bFire = event.bPressed;
489  else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)
490  {
491    this->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;
492  }
493  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
494    this->previousWeaponConfig();
495  else if( event.type == KeyMapper::PEV_UP)
496    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
497  else if( event.type == KeyMapper::PEV_DOWN)
498    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
499  else if( event.type == EV_MOUSE_MOTION)
500  {
501    this->xMouse += event.xRel;
502    this->yMouse += event.yRel;
503  }
504}
505
506#include "weapons/aiming_turret.h"
507// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
508void SpaceShip::ADDWEAPON()
509{
510  Weapon* turret = NULL;
511
512  if ((float)rand()/RAND_MAX < .9)
513  {
514    //if (this->getWeaponManager()->hasFreeSlot(2, WTYPE_TURRET))
515    {
516      turret = new Turret();
517      this->addWeapon(turret, 2);
518      this->getWeaponManager()->changeWeaponConfig(2);
519    }
520  }
521  else
522  {
523    //if (this->getWeaponManager()->hasFreeSlot(3))
524    {
525      turret = dynamic_cast<Weapon*>(Factory::fabricate(CL_TARGETING_TURRET));
526      if (turret != NULL)
527      this->addWeapon(turret, 3);
528
529      this->getWeaponManager()->changeWeaponConfig(3);
530    }
531  }
532
533  if(turret != NULL)
534  {
535    turret->setName("Turret");
536    turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
537  }
538}
539
540#define MASK_bUp         1
541#define MASK_bDown       2
542#define MASK_bLeft       4
543#define MASK_bRight      8
544#define MASK_bAscend    16
545#define MASK_bDescend   32
546#define MASK_bFire      64
547#define MASK_bRollL    128
548#define MASK_bRollR    256
549
550#define DATA_state       1
551#define DATA_flags       2
552#define DATA_mouse       3
553
554int SpaceShip::writeBytes( const byte * data, int length, int sender )
555{
556  SYNCHELP_READ_BEGIN();
557
558  byte b;
559
560  do
561  {
562    SYNCHELP_READ_BYTE( b );
563
564    if ( b == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )
565    {
566     PRINTF(0)("GOT STATE %d\n", this->getUniqueID());
567     setRequestedSync( false );
568     setIsOutOfSync( false );
569     SYNCHELP_READ_FKT( WorldEntity::writeState );
570     //SYNCHELP_READ_FLOAT( cycle );
571
572      return SYNCHELP_READ_N;
573    }
574
575
576    //TODO: do not recieve data if you are the owner
577    if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ )
578    {
579      int flags = 0;
580      SYNCHELP_READ_INT( flags );
581
582      bUp = (flags & MASK_bUp) != 0;
583      bDown = (flags & MASK_bDown) != 0;
584      bLeft = (flags & MASK_bLeft) != 0;
585      bRight = (flags & MASK_bRight) != 0;
586      bAscend = (flags & MASK_bAscend) != 0;
587      bDescend = (flags & MASK_bDescend) != 0;
588      bFire = (flags & MASK_bFire) != 0;
589      bRollL = (flags & MASK_bRollL) != 0;
590      bRollR = (flags & MASK_bRollR) != 0;
591
592    }
593
594    //TODO: do not recieve data if you are the owner
595    if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ )
596    {
597      SYNCHELP_READ_FLOAT( mouseDir.w );
598      SYNCHELP_READ_FLOAT( mouseDir.v.x );
599      SYNCHELP_READ_FLOAT( mouseDir.v.y );
600      SYNCHELP_READ_FLOAT( mouseDir.v.z );
601    }
602  } while( b != 0 );
603
604  /*if ( b == DATA_mouse && this->getHostID()!=this->getOwner() )
605  {
606    SYNCHELP_READ_FLOAT( xMouse );
607    SYNCHELP_READ_FLOAT( yMouse );
608    SYNCHELP_READ_FLOAT( mouseSensitivity );
609    SYNCHELP_READ_FLOAT( cycle );
610}*/
611
612  if ( this->getOwner() != this->getHostID() )
613    SYNCHELP_READ_FKT( PNode::writeSync );
614
615  return SYNCHELP_READ_N;
616}
617
618
619
620int SpaceShip::readBytes( byte * data, int maxLength, int * reciever )
621{
622  SYNCHELP_WRITE_BEGIN();
623
624  if ( isOutOfSync() && !requestedSync() /*&& this->getHostID()!=this->getOwner()*/ )
625  {
626    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
627    setRequestedSync( true );
628    PRINTF(0)("REQUESTED STATE %d\n", this->getUniqueID());
629  }
630
631  int rec = this->getRequestSync();
632  if ( rec > 0 )
633  {
634    *reciever = rec;
635
636    PRINTF(0)("SEND STATE %d %d\n", this->getUniqueID(), rec);
637
638    SYNCHELP_WRITE_BYTE( (byte)DATA_state );
639
640    SYNCHELP_WRITE_FKT( WorldEntity::readState );
641    //SYNCHELP_WRITE_FLOAT( cycle );
642
643    return SYNCHELP_WRITE_N;
644  }
645
646  *reciever = 0;
647
648  if ( this->getHostID()==this->getOwner() )
649  {
650    int mask = 0;
651
652    if ( bUp )
653      mask |= MASK_bUp;
654    if ( bDown )
655      mask |= MASK_bDown;
656    if ( bLeft )
657      mask |= MASK_bLeft;
658    if ( bRight )
659      mask |= MASK_bRight;
660    if ( bAscend )
661      mask |= MASK_bAscend;
662    if ( bFire )
663      mask |= MASK_bFire;
664    if ( bRollL )
665      mask |= MASK_bRollL;
666    if ( bRollR )
667      mask |= MASK_bRollR;
668
669
670    //static float oldxMouse = xMouse + 1.0;
671    //static float oldyMouse = yMouse + 1.0;
672
673    if ( mask != oldMask )
674    {
675      oldMask = mask;
676      SYNCHELP_WRITE_BYTE( DATA_flags );
677      SYNCHELP_WRITE_INT( mask );
678    }
679#define __OFFSET_ROT 0.05
680    if ( fabs( oldMouseDir.w - mouseDir.w ) > __OFFSET_ROT ||
681         fabs( oldMouseDir.v.x - mouseDir.v.x ) > __OFFSET_ROT ||
682         fabs( oldMouseDir.v.y - mouseDir.v.y ) > __OFFSET_ROT ||
683         fabs( oldMouseDir.v.z - mouseDir.v.z ) > __OFFSET_ROT )
684    {
685      oldMouseDir = mouseDir;
686
687      SYNCHELP_WRITE_BYTE( DATA_mouse );
688      SYNCHELP_WRITE_FLOAT( mouseDir.w );
689      SYNCHELP_WRITE_FLOAT( mouseDir.v.x );
690      SYNCHELP_WRITE_FLOAT( mouseDir.v.y );
691      SYNCHELP_WRITE_FLOAT( mouseDir.v.z );
692    }
693
694  }
695
696  SYNCHELP_WRITE_BYTE( 0 );
697
698
699  if ( this->getOwner() == this->getHostID() )
700    SYNCHELP_WRITE_FKT( PNode::readSync );
701
702  return SYNCHELP_WRITE_N;
703}
Note: See TracBrowser for help on using the repository browser.