void GameMap1GraphicsComponent::loadMesh(void) { int i,j,k; D3DXVECTOR3 rowPos(0.0,0.0,0.0); D3DXVECTOR3 colPos(0.0,0.0,0.0); D3DCOLOR initialColor = D3DCOLOR_XRGB(127, 130, 127); float rangeMax = 10; float rangeMin = 0; numVtx = numRows*numCols; this->numRows = numRows; this->numCols = numCols; this->dx = dx; this->dz = dz; float texCoordStepX = 10.0f/numCols; float texCoordStepY = 10.0f/numRows; numQuads = (numRows-1) * (numCols-1); numTriangles = numQuads * 2; numIndices = numTriangles * 3; // allocate memory vtx = (struct MeshVertex *) malloc(sizeof(struct MeshVertex) * numVtx); if (vtx == NULL) { // error goto err; } ind = (long *) malloc(sizeof(long) * numTriangles * 3); if (ind == NULL) { // error goto err; } // Fill the vertex buffer with positions k = 0; for(i = 0; i < numRows; i++) { // assign the pos vector for all comumns in a row colPos = rowPos; for(j = 0; j < numCols; j++) { // Negate the depth coordinate to put in quadrant four. // Then offset to center about coordinate system. vtx[k].pos = colPos; //vtx[k].pos.y = (long)((double)rand()/(RAND_MAX+1) * (rangeMax - rangeMin) // + rangeMin); vtx[k].pos.y = 0; //vtx[k].color = initialColor; vtx[k].normal = D3DXVECTOR3(0, 1, 0); vtx[k].tex1 = D3DXVECTOR2(j*texCoordStepX, i*texCoordStepY); colPos.x += dx; k++; } rowPos.z += dz; } // fill the index buffer k = 0; for(i = 0; i < numRows-1; i++) { for(j = 0; j < numCols-1; j++) { // fill indices for the quad ind[k++] = i * numCols + j; ind[k++] = (i+1) * numCols + j + 1; ind[k++] = i * numCols + j + 1; ind[k++] = i * numCols + j; ind[k++] = (i+1) * numCols + j; ind[k++] = (i+1) * numCols + j + 1; } } this->createGraphicsBuffers(); err: // clean up FREE_MEMORY_MALLOC(vtx); FREE_MEMORY_MALLOC(ind); }
/** Sets the value of the field in the @c ExtentSeries' current record. Note that @param val must be the correct size (or NULL) Preconditions: - The name of the Field must have been set and the associated @c ExtentSeries must have a current record. @param val source value for the copy @param val_size size of the value */ void set(const void *val, uint32_t val_size = 0) { DEBUG_SINVARIANT(dataseries.hasExtent()); set(dataseries.getExtentRef(), rowPos(), val, val_size); }
/** Returns the value of the field in the @c ExtentSeries' current record. Preconditions: - The name of the Field must have been set and the @c ExtentSeries must have a current record. */ const byte *val() const { DEBUG_SINVARIANT(dataseries.hasExtent()); return val(dataseries.getExtentRef(), rowPos()); }
/** Returns the value of the field in the @c ExtentSeries' current record. Preconditions: - The name of the Field must have been set and the @c ExtentSeries must have a current record. */ const byte *val(const Extent &e, const dataseries::SEP_RowOffset &row_offset) const { return val(e, rowPos(e, row_offset)); }
/** Sets the value of the field in the @c ExtentSeries' current record. Note that @param val must be the correct size (or NULL) Preconditions: - The name of the Field must have been set and the associated @c ExtentSeries must have a current record. @param e Extent in which set the value @param row_offset Offset of the row to be set @param val source value for the copy @param val_size size of the value */ void set(Extent &e, const dataseries::SEP_RowOffset &row_offset, const void *val, uint32_t val_size = 0) { set(e, rowPos(e, row_offset), val, val_size); }