Request: Mesh importing and Origin formula.

Discussions about Coding and Scripting
Post Reply
User avatar
ExpEM
Adept
Posts: 298
Joined: Wed Nov 09, 2016 1:48 am

Request: Mesh importing and Origin formula.

Post by ExpEM »

The story:
My original entry for AMC was to build a Domination map with a single Control Point guarded by a quadrupedal, gun heavy mech that would change team to whichever team owned said Control Point. The map itself is built, the code for the quadruped is in late beta, the meshes for the quadruped are done and... Shit... in the wrong place...

Extra info:
The meshes were all built in-Ed and converted using Mesh Maker, I know I can fix the mesh origins in the Exec code while importing. The problem is in finding the correct values. I can't figure out for the life of me how to calculate the correct values to have the Origin placed in the correct location.

I'm thinking some kind of formula must exist. Using the known values of the mesh (Scale etc) and the number of uu in-Ed per Axis the origin needs to be shifted.

The request:
Can some one please help me out with said formula. How do I work out the offsets to shift the Origin X-uu, Y-uu and Z-uu?
Signature goes here.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Request: Mesh importing and Origin formula.

Post by JackGriffin »

I've done this exact thing a ton of times and there's no real answer outside of trial and error. It's been my experience that when you import a mesh and scale it using the exec imports that it has no impact on the location of the origin in reference to the mesh. Let me explain a little more...Say you import a mesh and downscale it some crazy amount like importing at 0.05 size so it's the correct size in-game. Even though you scaled it down a crazy amount the origin will still be assigned by the amounts specified in the exec line and these are in reference to the editor grid coordinates and not the model coordinates.

I've never found a shortcut to setting a correct origin and collision. It's taken at times many tens of iterations testing different values to get it just where it looks perfect. I remember a couple of the food fight weapons were very hard to get everything right. If there is a "formula" for this it seems to me like it would be dependent on your modelling software because some tools import models at a much larger default size. I'm really interested in what real model makers have to say in reply to you. This has always nagged at me too.
So long, and thanks for all the fish
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: Request: Mesh importing and Origin formula.

Post by Higor »

Rule of 3.

Import the same mesh 4 times with 4 different names:

Code: Select all

%n_Org
%n_XO
%n_YO
%n_ZO
Offset _XO by X=100, _YO by Y=100, _ZO by Z=100

Compare the individual origin coordinates to _ORG and calculate ideal offset, MSPAINT is your friend:

Code: Select all

IdealX = (Pixels between _ORG.X and Ideal.X) / (Pixels between _ORG.X and _XO.X) //NEGATIVE IF IN OPPOSITE DIRECTION!

Code: Select all

IdealY = (Pixels between _ORG.Y and Ideal.Y) / (Pixels between _ORG.Y and _XO.Y) //NEGATIVE IF IN OPPOSITE DIRECTION!

Code: Select all

IdealZ = (Pixels between _ORG.Z and Ideal.Z) / (Pixels between _ORG.Z and _XO.Z) //NEGATIVE IF IN OPPOSITE DIRECTION!
Since you used 100 as offset for each coordinate, the ideal coordinates will be:

Code: Select all

X=100*IdealX
Y=100*IdealY
Z=100*IdealZ
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Request: Mesh importing and Origin formula.

Post by JackGriffin »

This shit is why I read these boards. Now I have to figure out a way to automate the process some....
So long, and thanks for all the fish
Post Reply