Apply the line's shear to the x/y rotation grid
This commit is contained in:
parent
80cb3d04c7
commit
d0bcc2e22c
6 changed files with 29 additions and 0 deletions
|
@ -415,6 +415,17 @@ void OpenGLWrapper::SetRotation(float x, float y, float z) {
|
||||||
glRotatef(z, 0.f, 0.f, -1.f);
|
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() {
|
void OpenGLWrapper::PrepareTransform() {
|
||||||
if (!transform_pushed) {
|
if (!transform_pushed) {
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
void SetScale(Vector2D scale);
|
void SetScale(Vector2D scale);
|
||||||
void SetOrigin(Vector2D origin);
|
void SetOrigin(Vector2D origin);
|
||||||
void SetRotation(float x, float y, float z);
|
void SetRotation(float x, float y, float z);
|
||||||
|
void SetShear(float x, float y);
|
||||||
void ResetTransform();
|
void ResetTransform();
|
||||||
|
|
||||||
void DrawLine(Vector2D p1, Vector2D p2) const;
|
void DrawLine(Vector2D p1, Vector2D p2) const;
|
||||||
|
|
|
@ -445,6 +445,17 @@ void VisualToolBase::GetLineRotation(AssDialogue *diag, float &rx, float &ry, fl
|
||||||
rz = tag->front().Get(rz);
|
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) {
|
void VisualToolBase::GetLineScale(AssDialogue *diag, Vector2D &scale) {
|
||||||
float x = 100.f, y = 100.f;
|
float x = 100.f, y = 100.f;
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ protected:
|
||||||
Vector2D GetLineOrigin(AssDialogue *diag);
|
Vector2D GetLineOrigin(AssDialogue *diag);
|
||||||
bool GetLineMove(AssDialogue *diag, Vector2D &p1, Vector2D &p2, int &t1, int &t2);
|
bool GetLineMove(AssDialogue *diag, Vector2D &p1, Vector2D &p2, int &t1, int &t2);
|
||||||
void GetLineRotation(AssDialogue *diag, float &rx, float &ry, float &rz);
|
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 GetLineScale(AssDialogue *diag, Vector2D &scale);
|
||||||
void GetLineClip(AssDialogue *diag, Vector2D &p1, Vector2D &p2, bool &inverse);
|
void GetLineClip(AssDialogue *diag, Vector2D &p1, Vector2D &p2, bool &inverse);
|
||||||
std::string GetLineVectorClip(AssDialogue *diag, int &scale, bool &inverse);
|
std::string GetLineVectorClip(AssDialogue *diag, int &scale, bool &inverse);
|
||||||
|
|
|
@ -41,6 +41,7 @@ void VisualToolRotateXY::Draw() {
|
||||||
// Transform grid
|
// Transform grid
|
||||||
gl.SetOrigin(org->pos);
|
gl.SetOrigin(org->pos);
|
||||||
gl.SetRotation(angle_x, angle_y, angle_z);
|
gl.SetRotation(angle_x, angle_y, angle_z);
|
||||||
|
gl.SetShear(fax, fay);
|
||||||
|
|
||||||
// Draw grid
|
// Draw grid
|
||||||
gl.SetLineColour(colour[0], 0.5f, 2);
|
gl.SetLineColour(colour[0], 0.5f, 2);
|
||||||
|
@ -178,4 +179,5 @@ void VisualToolRotateXY::DoRefresh() {
|
||||||
org->pos = FromScriptCoords(org->pos);
|
org->pos = FromScriptCoords(org->pos);
|
||||||
|
|
||||||
GetLineRotation(active_line, angle_x, angle_y, angle_z);
|
GetLineRotation(active_line, angle_x, angle_y, angle_z);
|
||||||
|
GetLineShear(active_line, fax, fay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@ class VisualToolRotateXY : public VisualTool<VisualDraggableFeature> {
|
||||||
float angle_y = 0.f; /// Current y rotation
|
float angle_y = 0.f; /// Current y rotation
|
||||||
float angle_z = 0.f; /// Current z 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_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
|
float orig_y = 0.f; ///< y rotation at the beginning of the current hold
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue