Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6746 in orxonox.OLD


Ignore:
Timestamp:
Jan 25, 2006, 11:22:50 PM (18 years ago)
Author:
patrick
Message:

network: converter adj

Location:
branches/network/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/graphics/graphics_engine.cc

    r6634 r6746  
    3535#include "globals.h"
    3636#include "texture.h"
     37
     38#include "effects/graphics_effect.h"
    3739
    3840#include "shell_command.h"
     
    655657
    656658}
     659
     660
     661/**
     662 * loads a GraphicsEffect into the engine
     663 * @param effect the GraphicsEffect to add
     664 */
     665void GraphicsEngine::loadGraphicsEffect(GraphicsEffect* effect)
     666{}
     667
     668
     669/**
     670 * unloads a GraphicsEffect from the engine
     671 * @param effect the GraphicsEffect to remove
     672 */
     673void GraphicsEngine::unloadGraphicsEffect(GraphicsEffect* effect)
     674{}
  • branches/network/src/lib/network/converter.cc

    r6744 r6746  
    197197    result /= 2.0f;
    198198  return result;
    199 }
    200 
    201 /*!
    202  * Converts a float value into a byte-array
    203  * @param x: The float which is to convert
    204  * @return: A byte-array which accords the given float
    205  */
    206 byte* Converter::floatToByteArray(float x)
    207 {
    208   byte* result = new byte[4];
    209   floatToByteArray(x, result, 4);
    210   return result;
    211   /*
    212   int mantisse = 0;
    213   int exponent = 128;
    214 
    215   int sgn;
    216   if (x < 0)
    217   {
    218     x = -x;
    219     sgn = -1;
    220   }
    221   else
    222     sgn = 1;
    223 
    224   if (x == 0)
    225   {
    226     exponent = 255;
    227     mantisse = 0;
    228   }
    229   else
    230   {
    231     //if (x < getDenormConst())
    232     //  printf("Denormalisiert!\n");
    233     //printf("DenormConst = %e", getDenormConst());
    234 
    235     float sub = 1;
    236     while (sub < x)
    237     {
    238       sub *= 2;
    239       exponent++;
    240     }
    241 
    242     while (x > 0)
    243     {
    244       if (x >= sub)
    245       {
    246         mantisse += 1;
    247         x -= sub;
    248       }
    249 
    250       mantisse *= 2;
    251       exponent--;
    252       sub /= 2;
    253     }
    254     exponent++;
    255     mantisse /= 2;
    256 
    257     printf("Conv:        mantisse = %i exponent = %i \n", mantisse, exponent);
    258 
    259 
    260     if (mantisse != 0)
    261     {
    262       while (mantisse < expmult)
    263       {
    264         mantisse *= 2;
    265         exponent--;
    266       }
    267 
    268       mantisse -= expmult;
    269     }
    270   }
    271 
    272   printf("Conv: mantisse = %i exponent = %i \n", mantisse, exponent);
    273 
    274 
    275   int hx = mantisse + expmult * exponent;
    276   byte* result = intToByteArray(hx);
    277   if (sgn == -1)
    278     result[3] += sgnadd;
    279 
    280   return result;
    281   */
    282 }
    283 
    284 
    285 /*!
    286  * Converts a byte-array into a float value
    287  * @param a: The byte-array which is to convert
    288  * @return: A float value which accords the given byte-array
    289  */
    290 float Converter::byteArrayToFloat(byte* a)
    291 {
    292   byte* h = new byte[4];
    293   float result = 0.0f;
    294   byteArrayToFloat(a, &result);
    295   return result;
    296   /*
    297   int hexp = a[2] + a[3] * 256;
    298   int exponent = (hexp / 128) % 256;
    299 
    300   int hmant = a[0] + a[1] * 256 + a[2] * 65536;
    301   int mantisse = hmant % expmult;
    302   if (mantisse == 0 && exponent == 255)
    303     return 0;
    304 
    305   mantisse += expmult;
    306   exponent -= 128;
    307 
    308 
    309   int sgn;
    310   if (a[3] >= sgnadd)
    311     sgn = -1;
    312   else
    313     sgn = 1;
    314 
    315   printf("ReConv: mantisse = %i exponent = %i \n", mantisse, exponent);
    316 
    317   float emult = 1;
    318   if (exponent > 0)
    319     for (int i = 0; i < exponent; i++)
    320       emult *= 2;
    321   else if (exponent < 0)
    322     for (int i = 0; i > exponent; i--)
    323       emult /= 2;
    324 
    325   float result = mantisse * emult;
    326   if (sgn == -1)
    327     result = -result;
    328 
    329   return result;
    330   */
    331199}
    332200
     
    651519  printf("To Convert: %e\n", x);
    652520
    653   byte* res = floatToByteArray(x);
    654   for (int i = 0; i < 4; i++)
    655     printf("%i ", res[i]);
    656   printf("\n");
    657 
    658   float y = byteArrayToFloat(res);
    659   printf("ReConvert: %e\n", y);
    660 
    661   if (x == y)
    662     printf("equal\n");
    663   else
    664     printf("different\n");
     521//  byte* res = floatToByteArray(x);
     522//   for (int i = 0; i < 4; i++)
     523//     printf("%i ", res[i]);
     524//   printf("\n");
     525
     526//  float y = byteArrayToFloat(res);
     527//   printf("ReConvert: %e\n", y);
     528
     529//   if (x == y)
     530//     printf("equal\n");
     531//   else
     532//     printf("different\n");
    665533}
    666534
  • branches/network/src/lib/network/converter.h

    r6740 r6746  
    3131    static int byteArrayToInt(const byte* a, int* x);
    3232
    33     static int floatToByteArray(float x, byte* a, int length);
    34     static int byteArrayToFloat(const byte* a, float* x);
    35 
    3633    static int stringToByteArray(const char* s, byte* a, int length, int maxLength);
    3734    static int byteArrayToString(const byte* a, char* s, int maxLength);
     
    4138    static char* floatToBinString(float x);
    4239
    43     static byte* floatToByteArray(float x);
    44     static float byteArrayToFloat(byte* a);
     40//     static byte* floatToByteArray(float x);
     41//     static float byteArrayToFloat(byte* a);
     42
     43    static int floatToByteArray(float x, byte* a, int length);
     44    static int byteArrayToFloat(const byte* a, float* x);
    4545
    4646    static int _floatToByteArray(float x, byte* a, int length);
    4747    static int _byteArrayToFloat(const byte* a, float* x);
     48
    4849
    4950
Note: See TracChangeset for help on using the changeset viewer.