Announcement

Collapse
No announcement yet.

calling all scripters!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • calling all scripters!

    i need a way to do the equivalent of hitting the "view align" button on the uvmap modifier, but continuously so the gizmo is constantly aligned to the view during animation. this is NOT the same as the lookat constraint, which (with some fiddling and issues) points the gizmo at the camera axis.

    the "view align" makes the gizmo parallel to the view plane and aligned vertically in the view.

    unfortunately its not exposed to maxscript.

    it must be possible mathematically speaking, since the button works?

    ideally i want something which does not require a rig, since i have to stick the thing on top of stuff thats already rigged up with lookat constraints and controllers for object position/rotation, and it will probably cause all sorts of issues if i need another mass of dummies and constraints.


    i have a budget available if its involved.

    need something relatively quickly.. so if i have any takers...

    stretch goal is the same thing, but for the "fit" button so the gizmo is fitted to the bounds of the object once view aligned.

    rights for any sellable script could remain with the creator.

  • #2
    I know you said no rig, but a thought or two for whoever will end up doing the job (well this is what came to mind anyway).

    1) Link a plane to the object you want the uv aligned to.
    2) Create a billboard affect for the plane which looks at the cam, letting it rotate only on 2 axis. (x and z for example if it was created in front view)
    3) Assuming the plane is called tempplane, get the quaternion of the plane with:
    Code:
    eulerToQuat (tempplane.transform as eulerAngles)
    4) Assuming the object with the UVW Map is called tempobject, select it (with script) and then align the uv's gizmo to the plane with:
    Code:
    tempobject.modifiers[#UVW_Map].gizmo.rotation = (eulerToQuat (tempplane.transform as eulerAngles))
    5) Now do that for each frame of the animation. It can be keyframed so then it can be easily rendered.

    In step 3 you can assign that to a variable then in step 4 it can make the line shorter....

    The plane is just there to get the quaternation, so you can set it to not renderable
    Last edited by Morne; 20-07-2021, 07:05 AM.
    Kind Regards,
    Morne

    Comment


    • #3
      Thanks Morne. ill take your word for it that this would work, im not actually sure what "quaternation" is!


      one thing that stood out was

      "Create a billboard affect for the plane which looks at the cam, letting it rotate only on 2 axis."

      the effect has to work on all 3 axis, with the uv gizmo parallel to the view and aligned "up" the screen, even if the cam is above and looking down. i need total freedom with cam or object movement, just as i have with using the "view align" button.

      apologies if i dont actually understand your method really, if i did i wouldnt need somebody to code it for me..!

      in my (frustratingly non mathematical) mind, i just need to read the camera rotation relative to world zero and apply the same rotation to the uv gizmo? of course its never that simple eh?

      baking whatever result to keyframes for the uv gizmo would be a good solution though.


      the only lead ( not a very complete one) i found online was this:

      https://discourse.techart.online/t/m...view-align/802

      Last edited by super gnu; 20-07-2021, 07:13 AM.

      Comment


      • #4
        Rotation is a bit more complex than the xyz position of something.
        Rotation can be measured in various different ways, eulerangles, quaternion, etc

        So for the plan bilboard affect, this is simply a cheat to align things to the camera in 2 axis only. This will work because you want it to rotate in z to follow the cam, however, you also want it to tilt in 1 axiz, x in my example, to be perpendicular to the camera. If you also rotate it in Y, that would mess up your rotation as the affect will be wrong as it rotate the UV sideways, meaning it will lean over left or right in view, which is what you dont want. Doing it only in x and z will result in the uvmap alignment being aligned to cam, but also keep the top to the top, instead of having it tilt left or right. Imagine a guy facing the camera. He turns left and right to always face the cam. This guy can lean forward or lean backward depending on how high the cam. However, in cam view you want him to always appear "vertical". If he leans over to his side left or right, he will not appear vertical anymore. There fore the plan needs to only align in 2 axis (while looking at the cam at same time)

        Trying to align the UV gizmo direct to the cam rotation, will be incorrect as you wont get a look at affect. Instead your uv will be angled which will be more aparent when the object is at the edges of the frame. Imagine again a guy standing, and NOT facing the camera this time, however he is looking in same direction as the camera. His gaze will be parallel to the camera gaze, which is fine if his eyes will always be in center of the view, but moving to the edges of the view, it will be more apparent he is looking in wrong direction. Therefore you need to use the temp dummy plane which will have a lookat to the cam and be linked in 2 axis, and then in turn you align the uvmap to this plane, resulting in it always facing the cam.

        EDIT:
        In the example you linked, and also in my code, the quaternion value is named shorter as just quat
        So basically you want to find the quat rotation of the plane and equal your object's uvmap's quat rotation to that
        Last edited by Morne; 20-07-2021, 07:46 AM.
        Kind Regards,
        Morne

        Comment


        • #5
          If you manually do things and hit the "View Align" button, you can see the CURRENT quaternion of that object's UVMap orientation by simply using this command while the object is selected
          Code:
          $.modifiers[#UVW_Map].gizmo.rotation
          Kind Regards,
          Morne

          Comment


          • #6
            Having a look at Artur's response in the link you sent, instead of using a UVWMap modifier, you can use a unwrap uvw modifier instead and use its maxscript access to align thigns. Anyway, I'll leave you to it....
            Kind Regards,
            Morne

            Comment


            • #7
              If I understand what gnu's looking for it can be achieved using the Unwrap_UVW modifier instead of the UVWMap modifier. It has a somewhat similar Planar Map option and a View Align option but it will also fit it at the same time(AFAIK it cannot only align it without the scaling). It can be called via "$.Unwrap_UVW.mappingAlignToView()" but it has to be in planar projection mode, hence the additional lines below. I guess an easy way to call it might be to just running the maxscript below as a Pre-Render script (there's probably other ways but my knowledge is limited).Just set the obj to the object you need remapped...
              Code:
              max modify mode
              obj=$Box001
              modPanel.setCurrentObject obj.Unwrap_UVW
              obj.Unwrap_UVW.mappingMode 1
              obj.Unwrap_UVW.mappingAlignToView()
              www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

              Comment


              • #8
                In my haste I forgot that the "Pre-Render" script is only evaluated once, not every frame so you'll need a way to call the script every frame. I can't recall how to get that to work but I'd imagine some type of callback?
                www.dpict3d.com - "That's a very nice rendering, Dave. I think you've improved a great deal." - HAL9000... At least I have one fan.

                Comment


                • #9
                  thanks Dlparsi...

                  this might be a usable approach, although "AFAIK it cannot only align it without the scaling" would be problematic if i dont wish the map to be scaled? its more likely it will need to remain at a fixed scale and aspect ratio and simply orient to the view. the scaling was an optional extra the client may ask to see.

                  Comment


                  • #10
                    Is this the sort of thing you want to do, or have I misunderstood?
                    https://vimeo.com/577277353/6f9b6ca62d
                    https://www.behance.net/bartgelin

                    Comment


                    • #11
                      that... looks.... exactly like what i want...! just simple parameter wiring?! ill need to try it to see if it behaves in my scenes, but... if it works ill feel quite silly

                      Comment


                      • #12
                        Hehe, yeah, very simple wiring for all rotations. Only thing is that it only works with a non-target camera, so not sure if that'll create another problem.
                        https://www.behance.net/bartgelin

                        Comment


                        • #13
                          ahh that might be an issue, using a lot of target cams.. but i guess i can always link a dummy to the camera and wire it to that?

                          Comment


                          • #14
                            Yeah, was just coming back to edit to that effect
                            https://www.behance.net/bartgelin

                            Comment


                            • #15
                              This is what I was saying about directly linking the uvgizmo to the z of the cam:
                              If the object is in the middle of the view, then fine, but when the object is at the edges of the frame, you are no longer facing the view, and also, besides z facing wrong, it may also not be upright as the cam may be rolling....

                              Click image for larger version  Name:	Capture.JPG Views:	0 Size:	16.7 KB ID:	1120112

                              Therefore the fake plane thought I was thinking of adding....

                              However, seeing the general result in "fixeighted"s vid, maybe that is all you need for the look you want, even though it ends up like the attached pic here


                              Last edited by Morne; 21-07-2021, 12:42 AM.
                              Kind Regards,
                              Morne

                              Comment

                              Working...
                              X