void Mesh::TransformVertices(Matrix44f transform) { for( unsigned int i = 0; i < this->_vertices.size(); ++i ) { Vertex* vertex = this->_vertices.at(i); if( vertex ) { vertex->Position() = (Vector3f)(transform*Vector4f(vertex->GetPosition(), 1.0f)); } } }
void Terrain::UpdateVertices() { if( this->IsValid() ) { for( int y = 0; y <= this->_size.height; ++y ) { for( int x = 0; x <= this->_size.width; ++x ) { Vertex* vertex = this->_heightMatrix+x+y*(this->_size.width+1); vertex->Position().x = (float)x + (float)this->_offset.x; vertex->Position().z = -(float)y - (float)this->_offset.y; vertex->TextureCoords().u = (float)x / (float)this->_size.width; vertex->TextureCoords().v = (float)y / (float)this->_size.height; vertex->Normal().x = 0.0f; vertex->Normal().y = 1.0f; vertex->Normal().z = 0.0f; } } } }