In the video I wave my cursor over the part of the code that scales the cube object (that has wireframe material) to match up with where the mouse cursor is, and I’ve provided the blend file below.
I’m not sure how to get a local location out of the mouse cursor, relative to where the cube object that scales is spawned. I might not be wording all this correctly, so my apologies for any misunderstandings. :spin:
You just need to rotate the indicator and the scaling vector by the camera’s orientation matrix (with the z-component removed since I assume you don’t want your selection box to move out of the 2D plane).
Here’s a handy function you can use to get that matrix:
If that’s the case, all you need to do is prevent the selection object from being rotated. You can do this by setting its orientation matrix to the identity matrix, or more simply by just adding it from an object that you know will never be rotated (the plane for example) instead of the rotated indicator.
I’m not exactly sure what you did, I see longer code, but the problem I stated in the video still remains.
Prevent it from being rotated? I’m trying to have it along the ground, but it align to the camera view, I succeed in aligning it to the camera view in the video, but the object scaling to the cursor is off when I rotate it.
I was wanting to know if there was a way to incorporate the rotation of the object in my code to give the scaling a sort of local location, where it will align with the mouse cursor regardless of rotation.
Well I am relatively new to using python for my games, and copy and paste your code as I might, I can’t seem to make it work.
You seem to be accessing stuff and terms I’ve never seen before, like,
yAxis.normalize()
I don’t know where you got yAxis from, or what objects Y axis you accessing, nor have I ever seen the term .normalize().
camMat.col[2] = [0, 0, 1]
yAxis = camMat.col[1]
I don’t know what a .col is or how you would get it from an objects orientation matrix, things like these are stumping me.
Judging by the structure of your code I’m sure you’ve achieved what I want, but the more I use these forums the more I realize there are so many things I’ve yet to learn in the python language, apparently some fundamentals as I can see. :spin:
So I haven’t tested it, I don’t know how to apply the code you’ve written.