Portierung Ogre3D/C++ nach Axiom3D/C# Code -> Frage zu C++ Code
-
Hallo zusammen,
ich mache im Moment (aus Neugierde um mit der Engine zu frickeln) eine Portierung von C++ Code (unter Nutzung der Ogre3D Libary) nach C# mit Axiom3D. Es geht um ein Minecraft Clone Beispiel
welches unter http://dave.uesp.net/wiki/Block_Land_3 beschrieben ist.Folgender C++ Ausschnitt bereitet mir Probleme, scheinbar ists zu lange her dass ich mit C++ gearbeitet habe.
Kann mir jemand erklären was hinter
GetBlock(x,y,z) = rand() % Divisor;
stecken könnte? Sieht wie ein Funktionsaufruf mit gleichzeitiger Wertezuweisung aus, aber mir ist nicht klar wie das gehen sollte? Kann mir jemand einen Denkanstoß geben? Ist eine Wertezuweisung auf den Ergebnistyp (hier block_t, ein Zeiger?) der vorher aus der Funktion ermittelt/zurückgegeben wird? Irgendwie sowas (Knoten im Kopf)?
Der ganze Code:
void TestBlockLandApplication::displaySimpleWorld (void) void TestBlockLandApplication::initWorldBlocksRandom (const int Divisor) { srand(12345); // To keep it consistent between runs for (int z = 0; z < WORLD_SIZE; ++z) { for (int y = 0; y < WORLD_SIZE; ++y) { for (int x = 0; x < WORLD_SIZE; ++x) { GetBlock(x,y,z) = rand() % Divisor; } } } }
typedef unsigned char block_t; class TestBlockLandApplication : public BaseApplication { ... static const int WORLD_SIZE = 16; // We'll change these later for various test worlds static const int CHUNK_SIZE = 16; int m_ChunkID; // Used for uniquely naming our chunks block_t* m_Blocks; // Holds the block worlds in a [WORLD_SIZE][WORLD_SIZE][WORLD_SIZE] array // Read/write access method for our block world (doesn't check input) block_t& GetBlock (const int x, const int y, const int z) { return m_Blocks[x + y * WORLD_SIZE + z * WORLD_SIZE * WORLD_SIZE]; } // Used for filling our block world void initWorldBlocksRandom (const int Divisor); void initWorldBlocksSphere (void); // Displays the world using our original "naive" method void displaySimpleWorld (void); };