Apply the line's shear to the x/y rotation grid

This commit is contained in:
Thomas Goyne 2013-12-14 07:45:26 -08:00
parent 80cb3d04c7
commit d0bcc2e22c
6 changed files with 29 additions and 0 deletions

View file

@ -415,6 +415,17 @@ void OpenGLWrapper::SetRotation(float x, float y, float z) {
glRotatef(z, 0.f, 0.f, -1.f);
}
void OpenGLWrapper::SetShear(float x, float y) {
PrepareTransform();
float matrix[16] = {
1, y, 0, 0,
x, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
glMultMatrixf(matrix);
}
void OpenGLWrapper::PrepareTransform() {
if (!transform_pushed) {
glMatrixMode(GL_MODELVIEW);

View file

@ -49,6 +49,7 @@ public:
void SetScale(Vector2D scale);
void SetOrigin(Vector2D origin);
void SetRotation(float x, float y, float z);
void SetShear(float x, float y);
void ResetTransform();
void DrawLine(Vector2D p1, Vector2D p2) const;

View file

@ -445,6 +445,17 @@ void VisualToolBase::GetLineRotation(AssDialogue *diag, float &rx, float &ry, fl
rz = tag->front().Get(rz);
}
void VisualToolBase::GetLineShear(AssDialogue *diag, float& fax, float& fay) {
fax = fay = 0.f;
boost::ptr_vector<AssDialogueBlock> blocks(diag->ParseTags());
if (param_vec tag = find_tag(blocks, "\\fax"))
fax = tag->front().Get(fax);
if (param_vec tag = find_tag(blocks, "\\fay"))
fay = tag->front().Get(fay);
}
void VisualToolBase::GetLineScale(AssDialogue *diag, Vector2D &scale) {
float x = 100.f, y = 100.f;

View file

@ -122,6 +122,7 @@ protected:
Vector2D GetLineOrigin(AssDialogue *diag);
bool GetLineMove(AssDialogue *diag, Vector2D &p1, Vector2D &p2, int &t1, int &t2);
void GetLineRotation(AssDialogue *diag, float &rx, float &ry, float &rz);
void GetLineShear(AssDialogue *diag, float& fax, float& fay);
void GetLineScale(AssDialogue *diag, Vector2D &scale);
void GetLineClip(AssDialogue *diag, Vector2D &p1, Vector2D &p2, bool &inverse);
std::string GetLineVectorClip(AssDialogue *diag, int &scale, bool &inverse);

View file

@ -41,6 +41,7 @@ void VisualToolRotateXY::Draw() {
// Transform grid
gl.SetOrigin(org->pos);
gl.SetRotation(angle_x, angle_y, angle_z);
gl.SetShear(fax, fay);
// Draw grid
gl.SetLineColour(colour[0], 0.5f, 2);
@ -178,4 +179,5 @@ void VisualToolRotateXY::DoRefresh() {
org->pos = FromScriptCoords(org->pos);
GetLineRotation(active_line, angle_x, angle_y, angle_z);
GetLineShear(active_line, fax, fay);
}

View file

@ -27,6 +27,9 @@ class VisualToolRotateXY : public VisualTool<VisualDraggableFeature> {
float angle_y = 0.f; /// Current y rotation
float angle_z = 0.f; /// Current z rotation
float fax = 0.f;
float fay = 0.f;
float orig_x = 0.f; ///< x rotation at the beginning of the current hold
float orig_y = 0.f; ///< y rotation at the beginning of the current hold