Changeset 6746 in orxonox.OLD for branches/network
- Timestamp:
- Jan 25, 2006, 11:22:50 PM (19 years ago)
- Location:
- branches/network/src/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/graphics/graphics_engine.cc
r6634 r6746 35 35 #include "globals.h" 36 36 #include "texture.h" 37 38 #include "effects/graphics_effect.h" 37 39 38 40 #include "shell_command.h" … … 655 657 656 658 } 659 660 661 /** 662 * loads a GraphicsEffect into the engine 663 * @param effect the GraphicsEffect to add 664 */ 665 void GraphicsEngine::loadGraphicsEffect(GraphicsEffect* effect) 666 {} 667 668 669 /** 670 * unloads a GraphicsEffect from the engine 671 * @param effect the GraphicsEffect to remove 672 */ 673 void GraphicsEngine::unloadGraphicsEffect(GraphicsEffect* effect) 674 {} -
branches/network/src/lib/network/converter.cc
r6744 r6746 197 197 result /= 2.0f; 198 198 return result; 199 }200 201 /*!202 * Converts a float value into a byte-array203 * @param x: The float which is to convert204 * @return: A byte-array which accords the given float205 */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 else222 sgn = 1;223 224 if (x == 0)225 {226 exponent = 255;227 mantisse = 0;228 }229 else230 {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 value287 * @param a: The byte-array which is to convert288 * @return: A float value which accords the given byte-array289 */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 else313 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 */331 199 } 332 200 … … 651 519 printf("To Convert: %e\n", x); 652 520 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 else664 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"); 665 533 } 666 534 -
branches/network/src/lib/network/converter.h
r6740 r6746 31 31 static int byteArrayToInt(const byte* a, int* x); 32 32 33 static int floatToByteArray(float x, byte* a, int length);34 static int byteArrayToFloat(const byte* a, float* x);35 36 33 static int stringToByteArray(const char* s, byte* a, int length, int maxLength); 37 34 static int byteArrayToString(const byte* a, char* s, int maxLength); … … 41 38 static char* floatToBinString(float x); 42 39 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); 45 45 46 46 static int _floatToByteArray(float x, byte* a, int length); 47 47 static int _byteArrayToFloat(const byte* a, float* x); 48 48 49 49 50
Note: See TracChangeset
for help on using the changeset viewer.