| 10 | { |
| 11 | |
| 12 | size_t Tesselator::tesselation( |
| 13 | size_t _count, |
| 14 | MyGUI::VectorQuadData& _data, |
| 15 | MyGUI::ITexture* _texture, |
| 16 | const MyGUI::RenderTargetInfo& _info, |
| 17 | const MyGUI::IntCoord& _coord) |
| 18 | { |
| 19 | mLeft = ((_info.pixScaleX * (float)(_coord.left) + _info.hOffset) * 2) - 1; |
| 20 | mTop = -(((_info.pixScaleY * (float)(_coord.top) + _info.vOffset) * 2) - 1); |
| 21 | |
| 22 | mWidth = (_info.pixScaleX * (float)_coord.width * 2); |
| 23 | mHeight = -(_info.pixScaleY * (float)_coord.height * 2); |
| 24 | |
| 25 | size_t count = mCountX * mCountY; |
| 26 | if (_count == count) |
| 27 | return count; |
| 28 | |
| 29 | // запрашивам нужный размер вершин |
| 30 | _data.resize(count); |
| 31 | |
| 32 | float vertex_z = _info.maximumDepth; |
| 33 | |
| 34 | float texture_u = (float)_coord.width / (float)_texture->getWidth(); |
| 35 | float texture_v = (float)_coord.height / (float)_texture->getHeight(); |
| 36 | |
| 37 | for (int rx = 0; rx < mCountX + 1; rx++) |
| 38 | { |
| 39 | for (int ry = 0; ry < mCountY + 1; ry++) |
| 40 | { |
| 41 | MyGUI::FloatPoint point((float)rx / (float)mCountX, (float)ry / (float)mCountY); |
| 42 | |
| 43 | float fx = mLeft + mWidth * point.left; |
| 44 | float fy = mTop + mHeight * point.top; |
| 45 | |
| 46 | float u = texture_u * point.left; |
| 47 | float v = texture_v * point.top; |
| 48 | |
| 49 | //if (_info.rttFlipY) v = 1 - v; |
| 50 | |
| 51 | MyGUI::Vertex vertex{fx, fy, vertex_z, 0xFFFFFFFF, u, v}; |
| 52 | |
| 53 | if (rx < mCountX && ry < mCountY) |
| 54 | { |
| 55 | _data[rx + ry * mCountX].vertex[MyGUI::QuadData::CornerLT] = vertex; |
| 56 | } |
| 57 | |
| 58 | if (rx > 0 && ry > 0) |
| 59 | { |
| 60 | _data[(rx - 1) + (ry - 1) * mCountX].vertex[MyGUI::QuadData::CornerRB] = vertex; |
| 61 | } |
| 62 | |
| 63 | if (rx > 0 && ry < mCountY) |
| 64 | { |
| 65 | _data[(rx - 1) + ry * mCountX].vertex[MyGUI::QuadData::CornerRT] = vertex; |
| 66 | } |
| 67 | |
| 68 | if (rx < mCountX && ry > 0) |
| 69 | { |