Author : afisher


Reply
Reply
 
Thread Tools Display Modes
SirCalalot's Avatar
Old (#1)
Hi all,

Sorry to create another thread on .fbx exporting, but I thought I'd pose you a query:

I have my environment blocked out in Maya and plan to export it into UDK as an .fbx file.
Now I know that I'll have to go through and manually delete and replace all of my instanced objects, (-_-) but I was wondering if anyone knew of a way to centre the pivot of each static mesh based on its Maya pivot?

As it stands, each mesh has its exported pivot at the origin - which kind of defeats the object of being able to import them all under one file if I'm being honest.

Is there a check box I'm missing? There appears to be no documentation that I can find on the subject and I'm hoping that I won't have to go through and manually place every object back at the origin before exporting them all one-by-one.

Help me Polycount, you're my only hope.
Offline , polycounter, 859 Posts, Join Date Nov 2011, Location Birmingham, UK  
   Reply With Quote

passerby's Avatar
Old (#2)
i just made a mel script that does a batch export of my objects, and moves them to 0 0 0 before export and puts them back after.

pretty simple thing to make.
Offline , card carrying polycounter, 2,243 Posts, Join Date Nov 2010, Location Halifax, NS, Canada  
   Reply With Quote

SirCalalot's Avatar
Old (#3)
A very good idea!
Would that still work for objects moved from the origin and had 'Freeze Transformations' applied?
Or does it work on World-space values rather than object-space?
Offline , polycounter, 859 Posts, Join Date Nov 2011, Location Birmingham, UK  
   Reply With Quote

passerby's Avatar
Old (#4)
doesn't matter if transformations are frozen or not.

Code:
global proc UDKexport() {
	string $selection[] = `ls -sl`;
	string $thisObj;
	string $presetpath = `internalVar -usd` + "UDK-FBX.fbxexportpreset";
	FBXLoadExportPresetFile -f $presetpath;
	int $selsize = size($selection);
    
	if ($selsize == 0) {
		warning("Nothing is Selected");
	}
	else {
		for ($thisObj in $selection) {
		select $thisObj;
		$OrginalLoc = `xform -q -piv -ws`;
		centerObj($thisObj);
		doexport($thisObj);
		move -r $OrginalLoc[0] $OrginalLoc[1] $OrginalLoc[2] $thisObj;
		}
	}
}	

// Center Object in Scene
global proc centerObj(string $objSelection){
        select -r $objSelection;
        makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
        $Pos = `xform -q -piv -ws`;
        move -a  (-1 *  $Pos[0]) (-1*$Pos[1] ) (-1*$Pos[2]) ;
}

//Start Export
global proc doexport(string $selExport) {
	string $extension = ".fbx";
	string $ExportPath;
	string $rootdir = `workspace -q -rd`;
	$ExportPath = ($rootdir + "data/" + $selExport + $extension);
	select $selExport;
	FBXExport -f $ExportPath -s;
}
you will prolly want to edit it to your liking, since it currently chooses the export path based on the active project in maya.

can toss that in your scripts folder, with the name "UDKexport.mel", and make a shelf button with "UDKexport();" and it should work for you.

edit: also forgot it requires a fbx preset be made name it "UDK-FBX.fbxexportpreset" and also put it in your scripts folder.

Last edited by passerby; 06-20-2012 at 12:24 PM..
Offline , card carrying polycounter, 2,243 Posts, Join Date Nov 2010, Location Halifax, NS, Canada  
   Reply With Quote

haiddasalami's Avatar
Old (#5)
I had an FBX batch Exporter I posted a while back. Its similar to Passerby's haha and also reminds me I need to re-do some stuff.
WebGL Project - In a state of constant flux so might be down when you check it. Pretty old now.
Junior Technical Artist at Digital Extremes.
Offline , dedicated polycounter, 1,859 Posts, Join Date Nov 2009, Location Toronto  
   Reply With Quote

passerby's Avatar
Old (#6)
ya i was using your script before i made that, i wanted to get rid of any reliance on a UI or needing to setup the path, and i always use projects in maya, so i made that.
Offline , card carrying polycounter, 2,243 Posts, Join Date Nov 2010, Location Halifax, NS, Canada  
   Reply With Quote

SirCalalot's Avatar
Old (#7)
Thanks to the both of you!
I'll have a bash at using it when I'm back home next week

Edit: Hmm, I wonder if there is a way to make the script ignore objects that are instanced?
Offline , polycounter, 859 Posts, Join Date Nov 2011, Location Birmingham, UK  
   Reply With Quote

passerby's Avatar
Old (#8)
prolly possible, i will look into how sometime in the next day or 2.

that is prolly easier in max since it;s easier to tell a instance from a object, but i should be able to check for rednundent shape data, and not export those ones.
Offline , card carrying polycounter, 2,243 Posts, Join Date Nov 2010, Location Halifax, NS, Canada  
   Reply With Quote

haiddasalami's Avatar
Old (#9)
Code:
string $objects[] = `listRelatives -allParents $shapeNode`;
if (size($objects)>1){
       //Do whatever you want with the parent or instances. Parent is $objects[0]
}
Hope that helps. I'll try and see if I can get it incorporated in my FBX Exporter.
WebGL Project - In a state of constant flux so might be down when you check it. Pretty old now.
Junior Technical Artist at Digital Extremes.
Offline , dedicated polycounter, 1,859 Posts, Join Date Nov 2009, Location Toronto  
   Reply With Quote

SirCalalot's Avatar
Old (#10)
Legend.
I can't wait to try this out.
Offline , polycounter, 859 Posts, Join Date Nov 2011, Location Birmingham, UK  
   Reply With Quote

passerby's Avatar
Old (#11)
@haiddasalami how exactly would that code work, if i just wanted to exclude instances, from being exported?
Offline , card carrying polycounter, 2,243 Posts, Join Date Nov 2010, Location Halifax, NS, Canada  
   Reply With Quote

SirCalalot's Avatar
Old (#12)
You know, I still haven't tried this out yet.
I'm moving house over the next week or two, so things are going to be a bit hectic before I manage to give your methods a blast, guys.
Offline , polycounter, 859 Posts, Join Date Nov 2011, Location Birmingham, UK  
   Reply With Quote

haiddasalami's Avatar
Old (#13)
Hey sorry didnt see an update to the thread. Ill post later/edit this post with code to get it working
WebGL Project - In a state of constant flux so might be down when you check it. Pretty old now.
Junior Technical Artist at Digital Extremes.
Offline , dedicated polycounter, 1,859 Posts, Join Date Nov 2009, Location Toronto  
   Reply With Quote

haiddasalami's Avatar
Old (#14)
Code:
global proc stupidMayaGlobals(){

//Getting Selection
string $sel[] = `ls -sl`;

//Declaring outside loop so I can access it later
string $objects[];

//Cycle through selection
    for ($object in $sel){
        //Get shape node of current
       string $shapes[] = `listRelatives -shapes -path $object`;
       //Get parents of shape node
       $objects = `listRelatives -allParents $shapes[0]`;
    }
    
    //If size of the array is greater than 1, its instanced
    if(size($objects)>1){
           //Our original Mesh
           print $objects[0];
    }
}

stupidMayaGlobals();
WebGL Project - In a state of constant flux so might be down when you check it. Pretty old now.
Junior Technical Artist at Digital Extremes.
Offline , dedicated polycounter, 1,859 Posts, Join Date Nov 2009, Location Toronto  
   Reply With Quote

SirCalalot's Avatar
Old (#15)
Well, I finally got to a point in my project where I am exporting and so far so good!
You guys have been a massive help

Now, to see what they look like the other end in UDK...
Offline , polycounter, 859 Posts, Join Date Nov 2011, Location Birmingham, UK  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch