I'm trying to make a simple 3D editor, but I'm not sure how I should go about it. I have come up with two options:
What does "scale it to straight plane" means?
I meen this, it's a cube scaled by X axis to plane (sorry I can't register on imgur from my country)
What is the issue with axes when you scale? Axis direction does not change during scale, why would they be any problem at all for scaling forward or inverse?
I understand this may not be obvious from my explanation. It wasn't my main question, so I explained it badly. As I wrote in my Reddit post, for example, when I interact with a model face, all interactions happen on the display model. This model is affected by some global model transformation (not shader global transform, but it happens on the CPU side), in this case, scaling. Then, when the user applies scaling to the model's face, I need to scale in the direction of the axis the user is interacting with, because that is of course the expected behavior. For this I need apply scaling on the face that has not yet been transformed by the global model scale (as the display model has). If I just take the axis that I produce for interaction with the display model scaling, scaling will happen in the wrong direction."
So, if I get rid of the transformation that must affect the entire model globally, the interaction that is happening with the display model will occur in the same space, and I won't have that problem.
Sorry if it is still not clear what the problem is.
That is why I am asking if someone knows of a better solution than storing applied transformations for each vertex to prevent destroying vertex information.
Actually I meen "scale", "translate" it's different tool and is work well with just applying inverse matrix as you said to direction in wich I calculate in global space. It working because for translation I need only one axis (or direction in which I need move vertices) so I don't have some "non-uniformity".
Things bellow I tested without dividing scaling on gobal and model as been on this firt reddit post, so model transform looks like
m4x4 ModelTrans = Model->ScaleMat * Model->Axis;
Also applying scaling to face that scale only on basis vector (1, 0, 0) (0, 1, 0) (0, 0, 1) also work well (example). Here I already need apply scale matrix but in this case I just need move global basis to model space and I don't need to know current state of model scale because it already in "model space" for this case.
(I use row-mojor matrix so it's from left to right)
m4x4 InvRot = Transpose(Model->Axis); m4x4 Scale = ScaleMat(ScaleV); ResultScale = Model->Axis * Scale * InvRot;
ScaleV is just represent magnitude of scaling for some axis, for example scale by X axis wiil look like (1.1f, 1.0f, 1.0f) for example.
But when I need perform scale in arbitrary direction (as I said in post doing this on face of model just for example) I need perform full inverse transform so that after applying Model->ScaleMat vertices will be place in expeted position. In solution that you suggest it should looks like this?(maybe I wrong)
In this case vertices completely "go crazy"
m4x4 ScaleAxis = ScaleMat(ScaleV) * ToM4x4(Tool->Axis); ResultScale = ScaleAxis * InvRot * InvScale;
Result that looks more like closely for what I need but is also produces incorrect result (example)
m4x4 ScaleAxis = ToM4x4(Tool->Axis) * InvRot; m4x4 InvScaleAxis = Transpose(ScaleAxis); m4x4 Scale = ScaleAxis * ScaleMat(ScaleV) * InvScaleAxis; ResultScale = ResultScale * InvScale;If not looking that scale happen in not adequate speed, rotation happaning from my understanding because after apply InvScale transform, vectors in scale matrix not anymore orhogonal as I demonstrate on screen shot on reddit post.
Sorry for long replying I have a little time in the evening for test and to think carefully about this
ScaleV is just represent magnitude of scaling for some axis, for example scale by X axis wiil look like (1.1f, 1.0f, 1.0f) for example.
You have an axis you want to scale, i.e. Model->Axis so
Also applying scaling to face that scale only on basis vector (1, 0, 0) (0, 1, 0) (0, 0, 1) also work well (example). Here I already need apply scale matrix but in this case I just need move global basis to model space and I don't need to know current state of model scale because it already in "model space" for this case.
But when I need perform scale in arbitrary direction (as I said in post doing this on face of model just for example) I need perform full inverse transform so that after applying Model->ScaleMat vertices will be place in expected position. In solution that you suggest it should looks like this?(maybe I wrong)
In this case I need more data for right scaling. At first I used only 3 value as you said but this been not worked, that why I use Tool->Axis. At first I tested on uncalled model faces and when do test on scaled then that problem been arise.
1 2 3 4 5 6 | float scale = 2.f; Vec3 axis = (1, 0, 0); Mat4 rot = ...; Vec3 rot_axis = rot * axis; Vec3 scaled_axis = scale * rot_axis; |
1 2 3 4 5 6 7 | m4x4 InvT = InvRot * InvScale; v3 ScaleAxis = Tool->Axis.Row[AxisID]; v3 Scale = ScaleAxis * InvT; Scale *= ScaleFactor; v3 ScaleApply = Scale; |
1 2 | v3 ScaleAxis = Tool->Axis.Row[AxisID]; v3 Scale = ScaleAxis * InvT; |
1 2 | v3 Scale = ScaleAxis.Row[AxisID].xyz; Scale *= ScaleFactor; |