This is a long shot...
*Background*
I love the new OBJ to Subd import option thats available out of the box in version 4.
But I also need an import option that brings in objs without automaticly subdividing them. This is because I sketch out shapes in a poly modelor and bring them into Moi as reference.
*Attempted solution**
I've been using Max Smirnovs import obj script (ImportObj.v.1.5.2015.09.10) which is great and almost does the job. It simply brings in the obj and makes them into a surface/solid which is amazing and not something i've encountered anywhere else in such a user friendly manner.
*Problem*
The problem I have is the script has a normalise funtion built in. As far as I can tell it does some clever stuff and scales up any objs that fall within certain size parameters. This means any obj no matter what its export scale was or how tiny it might translate over to Moi is always scaled up to work in Moi. Clever stuff!
But what i've found is this can lead to objs being imported and scaled inconsistently. For example in Blender I might have a mesh thats 30cm x 30cm x 40cm. On import to Moi it comes in at 30cm x 30cm x 40cm. If I modify the Obj by insetting and extruding a face so its say 30cm x 30cm x 50cm. This could lead to the normalise function bringing the obj in at different measurements.
I'd really like Moi to match Blenders scale (its almost there) and remain consistent as I bring in other Objs i've created from Blender.
*Request*
I've played with the script myself and removed the normalise funtion. Doing this i've been able to get a consistently scaled import from Blender no matter the size and shape of the mesh. Yay! But the obj consistently imports at very very tiny sizes as there is no scaling anymore. If it was 3cm in Blender it ends up at 0.003cm or thereabouts in Moi I think.
Is there anyone here clever enough to mod the script so it doesnt normalise but instead scales up by a defined factor? If this factor could be editied in script then it would have a lot of great utility and be similiar to the obj scaling on import option you get in poly modelors.
This is the funtion (theres other related code) I removed but i'm not a coder so have no idea how to replace it with consistent scaling:
function normalizeObj (norm)
{
normalize = norm;
scale = 200/(max.x-min.x+max.y-min.y+max.z-min.z)/3
var scalelog = Math.pow(10, Math.round(Math.log(scale)/Math.log(10)));
if (scalelog>1) { scalelog /=10 }
scale = Math.round(scale/scalelog)*scalelog;
if (scale == 0) scale = scalelog;
if ( !normalize && scale<1 ) scale=1;
scale *=100;
if ( !normalize ) for ( v in vertices ) vertices[v] = moi.VectorMath.createPoint(vertices[v].x*scale, vertices[v].y*scale, vertices[v].z*scale);
if ( normalize ) for ( v in vertices ) vertices[v] = moi.VectorMath.createPoint((vertices[v].x-max.x/2-min.x/2)*scale, (vertices[v].y-max.y/2-min.y/2)*scale, (vertices[v].z-min.z)*scale);
scale /=100;
*Second request*
If obj import with a scaling option could become an official feature it would be amazingly useful.
Thanks in advance!!
|