A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4751

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

SRP5Labyrinth - mcpaste

SRP5Labyrinth

Von MC, 9 Jahre vorher, geschrieben in C++, aufgerufen 1'451 mal.
URL https://mcpaste.de/view/0f02c270 Einbetten
Paste herunterladen oder Rohtext anzeigen
  1. /******************************************************************************
  2.     file:       main.cpp
  3.     created:    12.4.2004
  4. ******************************************************************************/
  5.  
  6. #include <Windows.h>
  7. #include <Opcode.h>
  8. #include "box.h"
  9.  
  10. // Prototypes:
  11. bool collide( Box *box1, Box *box2 );
  12. bool SaveAsBitmap( char *szFile, BYTE **array, int width, int height );
  13.  
  14.  
  15. // Global Vars
  16. const int nHind = 10;  // Anzahl der Hindernisse
  17. const int nRob = 1;   // Anzahl der Roboterglieder
  18. int nTests = 0;
  19.  
  20. Box aHindernis[nHind];  // Unsere Hindernise
  21. Box aRoboter[nRob];     // Roboterteile
  22.  
  23.  
  24. int setCellColisionIndex(int width, int height, BYTE ** cspace){
  25.         for (int j = 0; j < nHind; j++){
  26.                 bool isCollided = collide(&aRoboter[0], &aHindernis[j]);
  27.                 nTests++;
  28.                 if (isCollided){
  29.                         cspace[width][height] = j + 1;
  30.                         return j + 1;
  31.                 }
  32.         }
  33.         return 0;
  34. }
  35.  
  36.  
  37. /*
  38.  *  main
  39.  */
  40. int main( )
  41. {
  42.     // Breite und Höhe des Konfigurationsraumes
  43.     int width  = 1000;
  44.     int height = 1000;
  45.     int x, y = 0;
  46.  
  47.     // Konfigurationsraum initialisieren ( Dynamische Größe )
  48.     // gleiche wie cpace[height][width]
  49.     BYTE **cspace = new BYTE*[width];
  50.     for ( x=0; x<width; x++ )
  51.     {
  52.         cspace[x] = new BYTE[height];
  53.         for ( y = 0; y<height; y++ )
  54.             cspace[x][y] = 0;
  55.     }
  56.  
  57.     // Hindernisse initialisieren
  58.     // Hierbei wird für jedes Hinderniss die Größe ( Skalierung ) und
  59.     // die Position im Raum gesetzt
  60.     aHindernis[0].Scale( 0.30f, 0.05f, 0.10f );     // QUADER1   0.30000    0.05000    0.10000
  61.     aHindernis[0].Translate( -0.7f, -0.4f, 0.0f );  // REFPOS   -0.7000000   -0.4000000    0.0000000    0.0000000    0.0000000    0.0000000
  62.  
  63.     aHindernis[1].Scale( 0.05f, 0.60f, 0.10f );     // QUADER2   0.05000    0.60000    0.10000
  64.     aHindernis[1].Translate( -0.25f, -0.30f, 0.0f );// REFPOS   -0.2500000   -0.3000000    0.0000000    0.0000000    0.0000000    0.0000000
  65.  
  66.     aHindernis[2].Scale( 0.25f, 0.05f, 0.10f );     // QUADER3   0.25000    0.05000    0.10000
  67.     aHindernis[2].Translate( -0.2f, 0.45f, 0.0f );  // REFPOS   -0.2000000    0.4500000    0.0000000    0.0000000    0.0000000    0.0000000
  68.  
  69.     aHindernis[3].Scale( 0.55f, 0.05f, 0.10f );     // QUADER4   0.55000    0.05000    0.10000
  70.     aHindernis[3].Translate( -0.15f, -0.25f, 0.0f );// REFPOS   -0.1500000   -0.2500000    0.0000000    0.0000000    0.0000000    0.0000000
  71.  
  72.     aHindernis[4].Scale( 0.1f, 0.05f, 0.10f );      // QUADER5   0.10000    0.05000    0.10000
  73.     aHindernis[4].Translate( -0.05f, 0.20f, 0.0f ); // REFPOS   -0.0500000    0.2000000    0.0000000    0.0000000    0.0000000    0.0000000
  74.  
  75.     aHindernis[5].Scale( 0.05f, 0.2f, 0.10f );      // QUADER6   0.05000    0.20000    0.10000
  76.     aHindernis[5].Translate( 0.05f, -0.6f, 0.0f );  // REFPOS    0.0500000   -0.6000000    0.0000000    0.0000000    0.0000000    0.0000000
  77.  
  78.     aHindernis[6].Scale( 0.05f, 0.25f, 0.10f );     // QUADER7   0.05000    0.25000    0.10000
  79.     aHindernis[6].Translate( 0.25f, 0.25f, 0.0f );  // REFPOS    0.2500000    0.2500000    0.0000000    0.0000000    0.0000000    0.0000000
  80.  
  81.     aHindernis[7].Scale( 0.05f, 0.25f, 0.10f );     // QUADER8   0.05000    0.25000    0.10000
  82.     aHindernis[7].Translate( 0.35f, -0.5f, 0.0f );  // REFPOS    0.3500000   -0.5000000    0.0000000    0.0000000    0.0000000    0.0000000
  83.  
  84.     aHindernis[8].Scale( 0.2f, 0.05f, 0.10f );      // QUADER9   0.20000    0.05000    0.10000
  85.     aHindernis[8].Translate( 0.45f, 0.15f, 0.0f );  // REFPOS    0.4500000    0.1500000    0.0000000    0.0000000    0.0000000    0.0000000
  86.  
  87.     aHindernis[9].Scale( 0.05f, 0.3f, 0.1f );       // QUADER10  0.05000    0.30000    0.10000
  88.     aHindernis[9].Translate( 0.2f, -0.15f, 0.0f );  // REFPOS    0.2000000   -0.1500000    0.0000000    0.0000000    0.0000000    0.0000000
  89.  
  90.     // Roboterglieder initialisieren
  91.     aRoboter[0].Scale( 0.07f, 0.07f, 0.20f );       // QUADER    0.07000    0.07000    0.20000
  92.     aRoboter[0].Translate( -0.05f, -0.05f, 0.0f );  // REFPOS   -0.0500000   -0.0500000    0.0000000    0.0000000    0.0000000    0.0000000
  93.  
  94.     // Startzeit
  95.     DWORD dwStart = GetTickCount();
  96.         printf("Starting the Calculation...\n");
  97.     // Konfigurationsraum aufbauen
  98.     // Ihr Code ...
  99.         int cellCount = width * height;
  100.         for (int i = 0; i < cellCount; i++){
  101.  
  102.                 int cWidth = i % width;
  103.                 int cHeight = (int)(i / width);
  104.  
  105.  
  106.                 float xIndex = cWidth - (width / 2);
  107.                 float yIndex = cHeight - (height / 2);
  108.  
  109.  
  110.                 aRoboter[0].Translate(xIndex / 1000, yIndex / 1000, 0.0f);
  111.  
  112.                 setCellColisionIndex(cWidth, cHeight, cspace);
  113.  
  114.         }
  115.  
  116.  
  117.  
  118.         // Zeit für das Aufstellen des Konfigurationsraumes ausgeben ( in ms )
  119.     DWORD dwElapsed = GetTickCount() - dwStart;
  120.     printf( "\nBerechnung dauerte %d ms\n", dwElapsed );
  121.     printf( "Anzahl Kollisionstests: %d\n", nTests );   // Anzahl Kollitionstests
  122.  
  123.     // Konfigurationsraum als Bitmap speichern
  124.     SaveAsBitmap( "cspace_prismatic.bmp", cspace, width, height );
  125.         system("pause");
  126.     return 0;
  127. }
  128.  
  129. /*
  130.  *  collide
  131.  *  Diese Funktion prüft ob die zwei Objekte, box1 und box2 kollidieren
  132.  *  Wenn sie kollidieren, wird true zurückgegeben, sonst false
  133.  */
  134. bool collide( Box *box1, Box *box2 )
  135. {
  136.     // Build a quantized no-leaf tree
  137.     Opcode::AABBTreeCollider TC;
  138.     Opcode::BVTCache ColCache;
  139.  
  140.     // Create a tree collider and setup it:
  141.     TC.SetFirstContact(true);
  142.     TC.SetFullBoxBoxTest(false);    // use coarse BV-BV tests
  143.     TC.SetFullPrimBoxTest(false);   // use coarse primitive-BV tests
  144.     TC.SetTemporalCoherence(false); // don't use temporal coherence
  145.  
  146.     // Setup BVTCache
  147.     ColCache.Model0 = &box1->m_OpModel;
  148.     ColCache.Model1 = &box2->m_OpModel;
  149.  
  150.     // Collision query
  151.     bool IsOk = TC.Collide( ColCache, &box1->m_Matrix, &box2->m_Matrix );
  152.  
  153.     // Get collision status => if true, objects overlap
  154.     bool Status = TC.GetContactStatus() != FALSE;
  155.  
  156.     return Status;
  157. }
  158.  
  159. /*
  160.  *  SaveAsBitmap
  161.  *  Speichert den Konfigurationsraum als Bitmap.
  162.  *  Parameter:
  163.  *  szFile  -   Dateiname
  164.  *  array   -   Das 2D Array mit dem Konfigurationsraum
  165.  *  width   -   Breite des Konfigurationsraum
  166.  *  height  -   Höhe des Konfigrationsraum
  167.  */
  168. bool SaveAsBitmap( char *szFile, BYTE **array, int width, int height )
  169. {
  170.     BITMAPFILEHEADER bmpFileHeader;
  171.     bmpFileHeader.bfType = *((int*)("BM"));     // Muss BM sein
  172.     bmpFileHeader.bfSize = 0;           // Größe der Bitmap Datei
  173.     bmpFileHeader.bfReserved1 = 0;      // Muss 0 sein
  174.     bmpFileHeader.bfReserved2 = 0;      // Muss 0 sein
  175.     bmpFileHeader.bfOffBits = 0;        // Offset, in Bytes, zwischen BITMAPFILEHEADE und den Bits
  176.  
  177.  
  178.     BITMAPINFOHEADER bmpInfoHeader;
  179.     bmpInfoHeader.biSize = sizeof( BITMAPINFOHEADER );
  180.     bmpInfoHeader.biWidth = width;
  181.     bmpInfoHeader.biHeight = height;
  182.     bmpInfoHeader.biPlanes = 1;
  183.     bmpInfoHeader.biBitCount = 8;
  184.     bmpInfoHeader.biCompression = BI_RGB;
  185.     bmpInfoHeader.biSizeImage = width * height * 1;
  186.     bmpInfoHeader.biXPelsPerMeter = 2834;
  187.     bmpInfoHeader.biYPelsPerMeter = 2834;
  188.     bmpInfoHeader.biClrUsed = 256;
  189.     bmpInfoHeader.biClrImportant = 256;
  190.  
  191.     FILE *pFile = fopen( szFile, "wb" );
  192.     if ( pFile == NULL )
  193.     {
  194.         printf( "Konnte Datei '%s' nicht erzeugen.\n", szFile );
  195.         return false;
  196.     }
  197.  
  198.     fwrite( &bmpFileHeader, sizeof( BITMAPFILEHEADER ), 1, pFile );
  199.     fwrite( &bmpInfoHeader, sizeof( BITMAPINFOHEADER ), 1, pFile );
  200.  
  201.     // Farbpalette zum Bild hinzufügen
  202.     static RGBQUAD colortable[] =
  203.     {
  204.         // B    G    R   0
  205.         { 255, 255, 255, 0},
  206.  
  207.         {   0,   0, 255, 0},    // Rot
  208.         {   0, 255,   0, 0},    // Grün
  209.         { 255,   0,   0, 0},    // Blau
  210.  
  211.         {   0, 255, 255, 0},    // Gelb
  212.         { 255,   0, 255, 0},    // Magenta
  213.         { 255, 255,   0, 0},    // Cyan
  214.  
  215.         {   0, 128, 255, 0},    // Oragne
  216.         { 255,   0, 128, 0},    // Weinrot
  217.         { 128, 255,   0, 0},    // Hell Grün
  218.         {   0, 255, 128, 0}     // Gift Grün
  219.  
  220.         // Wenn die Farben nicht reichen, hier neue hinzufügen
  221.     };
  222.  
  223.     int nCol = sizeof(colortable) / sizeof(RGBQUAD);
  224.     fwrite( colortable, sizeof(RGBQUAD), sizeof(colortable), pFile );
  225.  
  226.     // Alle restlichen Farben auf Schwarz setzen
  227.     for ( int i=nCol; i<256; i++ )
  228.     {
  229.         RGBQUAD  rgb;
  230.         rgb.rgbRed   = 0;
  231.         rgb.rgbGreen = 0;
  232.         rgb.rgbBlue  = 0;
  233.         rgb.rgbReserved = 0;
  234.         fwrite( &rgb, sizeof( RGBQUAD), 1, pFile );
  235.     }
  236.  
  237.     // Bits schreiben
  238.     bmpFileHeader.bfOffBits = ftell( pFile );
  239.     for ( int y=height-1; y>=0; y-- )
  240.     {
  241.         for ( int x=0; x<width; x++ )
  242.         {
  243.             putc( array[x][y], pFile );
  244.         }
  245.     }
  246.  
  247.     bmpFileHeader.bfSize = ftell( pFile );
  248.  
  249.     // File Header nochmal mit neuen Werten überschreiben
  250.     fseek( pFile, 0L, SEEK_SET );
  251.     fwrite( &bmpFileHeader, sizeof( BITMAPFILEHEADER ), 1, pFile );
  252.  
  253.     fclose( pFile );
  254.  
  255.     return true;
  256. }

Antwort auf "SRP5Labyrinth"

Hier kannst Du auf den Paste von oben antworten

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876