Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 30, 2006, 1:50:25 PM (18 years ago)
Author:
rennerc
Message:

finished some SynchronizeableVars classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc

    r7444 r7459  
    1616
    1717#include "synchronizeable_quaternion.h"
     18#include "converter.h"
    1819
    1920
    2021/**
    2122 * standard constructor
    22  * @todo this constructor is not jet implemented - do it
    23 */
    24 SynchronizeableQuaternion::SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
     23 */
     24SynchronizeableQuaternion::SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 4*INTSIZE, permission, priority )
    2525{
    2626  this->vPtrIn = ptrIn;
     
    3131/**
    3232 * standard deconstructor
    33 */
     33 */
    3434SynchronizeableQuaternion::~SynchronizeableQuaternion ()
    3535{
     
    4444int SynchronizeableQuaternion::writeToBuf( byte * buf, int maxLength )
    4545{
    46 #warning implement this
     46  int n = 0;
     47  int res;
     48 
     49  res = Converter::floatToByteArray( vPtrIn->v.x, buf, maxLength - n );
     50  assert( res > 0 );
     51  n += res;
     52 
     53  res = Converter::floatToByteArray( vPtrIn->v.y, buf, maxLength - n );
     54  assert( res > 0 );
     55  n += res;
     56 
     57  res = Converter::floatToByteArray( vPtrIn->v.z, buf, maxLength - n );
     58  assert( res > 0 );
     59  n += res;
     60 
     61  res = Converter::floatToByteArray( vPtrIn->w, buf, maxLength - n );
     62  assert( res > 0 );
     63  n += res;
     64 
     65  assert( 4*FLOATSIZE == n );
     66 
     67  return n;
    4768}
    4869
     
    5576int SynchronizeableQuaternion::readFromBuf( byte * buf, int maxLength )
    5677{
    57 #warning implement this
     78  assert( maxLength >= 4*FLOATSIZE );
     79 
     80  float x,y,z,w;
     81 
     82  int res;
     83  int n = 0;
     84 
     85  res += Converter::byteArrayToFloat( buf + n, &x );
     86  assert( res > 0 );
     87  n += res;
     88 
     89  res += Converter::byteArrayToFloat( buf + n, &x );
     90  assert( res > 0 );
     91  n += res;
     92 
     93  res += Converter::byteArrayToFloat( buf + n, &x );
     94  assert( res > 0 );
     95  n += res;
     96 
     97  res += Converter::byteArrayToFloat( buf + n, &w );
     98  assert( res > 0 );
     99  n += res;
     100 
     101  *vPtrOut = Quaternion( Vector(x, y, z), w );
     102 
     103  assert( res == 4*FLOATSIZE );
     104  return res;
    58105}
Note: See TracChangeset for help on using the changeset viewer.