bonjorno7 / SourceOps

A more convenient alternative to Blender Source Tools.
GNU General Public License v3.0
138 stars 14 forks source link

Add functionality to use a custom object as the origin (and scale, etc) #69

Closed McGravel closed 2 years ago

McGravel commented 2 years ago

Closes #42 Adds extra option to pick an object from which to specify position, rotation and scale as an input for the $origin and $scale values in the generated .qc file.

If no object is picked whilst using the custom object option, then settings default to 0 0 0 0 for the $origin, and 1 for the $scale.

Example images:

Old method still supported: image

Drop-down: image

Picked object: image

McGravel commented 2 years ago

Tested a bit and got it to compile, and it doesn't look like the origin is going where it's supposed to, so i'll look into this some more. I think it relates to the Units used by the scene. I'm using metres, but of course, Source uses something else -- Inches I think.

Will probably have to convert those!

Can it be assumed the user is using Metres as their chosen Units, or will some logic to convert be needed?

McGravel commented 2 years ago

Going to need some more thorough testing, although it works in concept. I used HLMV to try and match the values the selected object has in the viewport, although the magnitude may require adjustment. Couldn't find anything specifying the units used for the $origin command, because who needs to know that? 🙃

image

I'll mark this as ready for review at this point, because I don't think there's anything more I can think of to try!

SethTooQuick commented 2 years ago

I've always wondered if it was even worth keeping the $origin command? Couldn't it all just be done in addon? Always felt a bit tedious imo.

McGravel commented 2 years ago

I don't see why it couldn't be considered - would probably be a better solution than my current method of guessing numbers 😆

McGravel commented 2 years ago

Just going through and resolving the comments that I know i've done, sort of as a checklist.

McGravel commented 2 years ago

As for the custom object itself, i am unsure of its accuracy given that I still don't know what units the QC command uses, so it just kinda uses the scene units as raw numbers, which doesn't feel ideal, and I am unsure if it matches that well in HLMV, if only things like this were documented a bit better.

Maybe it doesn't matter too much?

McGravel commented 2 years ago

Alright, looks like the rotation is applied after the location, which means that if you have rotation at 90 for example, the translation will be fine for location, then it'll be rotated 90 degrees around the origin of the world, which throws the whole thing off unfortunately.

bonjorno7 commented 2 years ago

If you're wondering about the units, 1 in the QC means 1 in the SMD means 1 in Blender. 1 meter in Blender is 1 unit in Hammer, no need for any conversion.

McGravel commented 2 years ago

Quickly tested, and everything seems to still work. I believe this addresses everything you've posted for the 2nd review.