polygon node: early crude implementation

This commit is contained in:
itsmattkc
2020-05-05 00:22:49 +10:00
parent b6696f3161
commit c387ce1cd7
38 changed files with 611 additions and 93 deletions
+36 -22
View File
@@ -90,27 +90,9 @@ void MatrixGenerator::Retranslate()
NodeValueTable MatrixGenerator::Value(NodeValueDatabase &value) const
{
QMatrix4x4 mat;
// Position translate
QVector2D pos = value[position_input_].Get(NodeParam::kVec2).value<QVector2D>();
mat.translate(pos);
// Rotation
mat.rotate(value[rotation_input_].Get(NodeParam::kFloat).toFloat(), 0, 0, 1);
// Scale and Uniform Scale
QVector2D scale = value[scale_input_].Get(NodeParam::kVec2).value<QVector2D>();
if (value[uniform_scale_input_].Get(NodeParam::kBoolean).toBool()) {
scale.setY(scale.x());
}
mat.scale(scale);
// Anchor Point
mat.translate(-value[anchor_input_].Get(NodeParam::kVec2).value<QVector2D>());
// Push matrix output
NodeValueTable output;
QMatrix4x4 mat = GenerateMatrix(value);
NodeValueTable output = value.Merge();
output.Push(NodeParam::kMatrix, mat);
return output;
}
@@ -120,10 +102,42 @@ bool MatrixGenerator::HasGizmos() const
return true;
}
void MatrixGenerator::DrawGizmos(QPainter *p, const QRect& viewport) const
void MatrixGenerator::DrawGizmos(NodeValueDatabase &db, QPainter *p) const
{
p->setPen(Qt::white);
p->drawEllipse(viewport);
// Fold values into a matrix
QMatrix4x4 matrix = GenerateMatrix(db);
// Set QPainter transform to our matrix
p->setTransform(matrix.toTransform());
// Draw ellipse
p->drawEllipse(QRect(0, 0, 100, 100));
}
QMatrix4x4 MatrixGenerator::GenerateMatrix(NodeValueDatabase &value) const
{
QMatrix4x4 mat;
// Position translate
QVector2D pos = value[position_input_].Take(NodeParam::kVec2).value<QVector2D>();
mat.translate(pos);
// Rotation
mat.rotate(value[rotation_input_].Take(NodeParam::kFloat).toFloat(), 0, 0, 1);
// Scale and Uniform Scale
QVector2D scale = value[scale_input_].Take(NodeParam::kVec2).value<QVector2D>();
if (value[uniform_scale_input_].Take(NodeParam::kBoolean).toBool()) {
scale.setY(scale.x());
}
mat.scale(scale);
// Anchor Point
mat.translate(-value[anchor_input_].Take(NodeParam::kVec2).value<QVector2D>());
return mat;
}
void MatrixGenerator::UniformScaleChanged()