int main() { int size = 64; Mercator::Segment *s = new Mercator::Segment(0, 0, size); Mercator::Matrix<2, 2, Mercator::BasePoint> & base = s->getControlPoints(); base[0] = Mercator::BasePoint(10.f, 3.f); base[1].height() = 15.f; base[2] = Mercator::BasePoint(10.f, 10.f); base[3] = Mercator::BasePoint(9.32f, 1.9f); s->populate(); /* s->populateNormals(); float *n=s->getNormals(); i*/ //for (int i=0; i<=size; ++i) { int i=0; for (int j=0; j<=size; ++j) { std::cout << j << ":" << s->get(i,j) << ", " ; } //} /* std::cout << s->get(i,j) << " ; "; std::cout << n[j * size * 3 + i * 3 ] << " : "; std::cout << n[j * size * 3 + i * 3 + 1] << " : "; std::cout << n[j * size * 3 + i * 3 + 2]; std::cout << std::endl; } std::cout << std::endl; } */ Mercator::Terrain t; t.setBasePoint(0,0,10.0); t.setBasePoint(0,1,12.0); t.setBasePoint(1,0,14.0); t.setBasePoint(1,1,16.0); std::cout << t.getSegmentAtIndex(0,0); t.setBasePoint(1,1,12.0); std::cout << t.getSegmentAtIndex(0,0); std::cout << std::endl; return 0; }
void HeightMapUpdateTask::createHeightMapSegments() { for (SegmentStore::const_iterator I = mSegments.begin(); I != mSegments.end(); ++I) { Mercator::Segment* segment = *I; if (segment) { IHeightMapSegment* heightMapSegment = 0; Mercator::Matrix<2, 2, Mercator::BasePoint>& basePoints(segment->getControlPoints()); //If all of the base points are on the same level, and there are no mods, we know that the segment is completely flat, and we can save some memory by using a HeightMapFlatSegment instance. if (WFMath::Equal(basePoints[0].height(), basePoints[1].height()) && WFMath::Equal(basePoints[1].height(), basePoints[2].height()) && WFMath::Equal(basePoints[2].height(), basePoints[3].height()) && (segment->getMods().empty())) { heightMapSegment = new HeightMapFlatSegment(basePoints[0].height()); } else { HeightMapBuffer* buffer = mProvider.checkout(); if (buffer) { memcpy(buffer->getBuffer()->getData(), segment->getPoints(), sizeof(float) * segment->getSize() * segment->getSize()); heightMapSegment = new HeightMapSegment(buffer); } } if (heightMapSegment) { mHeightMapSegments.emplace_back(WFMath::Point<2>(segment->getXRef() / segment->getResolution(), segment->getZRef() / segment->getResolution()), heightMapSegment); } } } }