Closed Geetchopra closed 5 years ago
It seems like your pivot point of rotation is in front of the big sphere and radius of rotation is small so it never actually goes behind. I assume the issue is with you model.glsl What is the order of scaling, translation and rotation in your case? you might be applying translation and rotation in the wrong order.
I am doing rotation translation in model.glsl and in model_view_projection.glsl I'm calculating scaleprojectionviewmodel*point. Also in the above gif the translation vector is 0,0,0.
so you are applying rotation and translation twice?
model.glsl computes model matrix. Model matrix is a combination of scaling(S), translation(T) and rotation (R). Order of these operations matters. Make sure you figure out the correct order.
model_view_projection.vs takes a point and transforms it into screen space. To do that you need to transform the point into view space first using model (calculated using model.glsl) and view matrcies and finally bring it into screen space using proj matrix.
Fixing the order seemed to fix the issue, however in this output there is still no translation but it basically looks like the gif in the assignment handout. The only different is that the rotation is counter-clockwise instead of clockwise. Do I need to fix the rotation (and how would I do so) or would this suffice?
Looks like you did apply translation. What do you mean there is no translation? The direction of rotation doesn't matter. But if you want to change it just reverse the sign of the rotation angle.
My translation vector is currently 0,0,0 in the above output. Doesn't that mean there is no translation?
thats weird. If you dont apply translation to the moon, it will just be rotating at the origin.
are you sure you are not translating in model_view_projection.vs
Yes, I figured out the problem! I didn't know what was causing it but i'm adding a translation in model_view_projection.vs. It's in a step before the calculation of the projection. I ended up not needing to use translate.glsl since the translate vector is hardcoded anyway.
you should not use translate function in your model_view_projection.vs translation is part of the model matrix which you compute in model.glsl Then model matrix can be used in model_view_projection.vs
I'm not using the function, but I just added a vector to the input vector which translates the moon. Is that also not ok? I can't seem to get translation in model.glsl to work. I tried both orders of multiplication, rotation translation and translation rotation.
Just fixed it! Everything works as intended now. It was another ordering issue. Thanks a lot!
I don't know what I am missing when applying a translation to the moon. If we need to hardcode the values of t what kind of values are we expected to input, and is it a uniform translation? The reason I ask is because even a value of 0.1 seems to only translate one corner of the moon. Also, will fixing the translation fix the moon not going "behind" the earth or is that another problem?
This is the current output without any translation, and with another hardcoded value to shift the origin of the moon around which it rotates. Please excuse the poor quality gif, its only a recording issue, it runs smoothly on my system.