added rect shape with corrected uv interpolation

This commit is contained in:
2017-01-18 23:01:00 +00:00
parent 5f6bcda211
commit 90ee10405d
3 changed files with 51 additions and 9 deletions

View File

@@ -24,14 +24,15 @@ protected:
{
static float d[4];
static vertex_t* v[4];
v[0] = &va; v[1] = &vb; v[2] = &vc; v[3] = &vc;
v[0] = &va; v[1] = &vb; v[2] = &vc; v[3] = &vd;
auto mid = quad_mid_point(va.pos, vb.pos, vc.pos, vd.pos);
for (int i = 0; i < 4; i++)
d[i] = glm::distance(glm::vec2(v[i]->pos), mid);
for (int i = 0; i < 4; i++)
{
float q = (d[i] + d[(i + 2) % 4]) / d[(i + 2) % 4];
v[i]->uvs = glm::vec4(glm::vec2(v[i]->uvs), 0, 1) * q;
v[i]->uvs = glm::vec2(v[i]->uvs) * q;
v[i]->pos.w = q;
}
}
};
@@ -50,6 +51,11 @@ public:
}
};
class Rect : public Shape
{
bool create(float w, float h);
};
class Circle : public Shape
{
public: